Activity Forums Salesforce® Discussions How can we dynamically create a chart using javascript?

  • Abhinav

    Member
    August 11, 2016 at 4:39 pm

    Hi Mohit,

    Below is the sample code :-

    <apex:page>
    <script>
    function getRemoteData(callback) {
    PieChartController.getRemotePieData(function(result, event) {
    if(event.status && result && result.constructor === Array) {
    callback(result);
    }
    });
    }
    </script>

    <apex:chart data="getRemoteData" ...></apex:chart>
    </apex:page>

    @RemoteAction
    public static List<PieWedgeData> getRemotePieData() {
    List<PieWedgeData> data = new List<PieWedgeData>();
    data.add(new PieWedgeData('Jan', 30));
    data.add(new PieWedgeData('Feb', 15));
    data.add(new PieWedgeData('Mar', 10));
    data.add(new PieWedgeData('Apr', 20));
    data.add(new PieWedgeData('May', 20));
    data.add(new PieWedgeData('Jun', 5));
    return data;
    }

  • Shekhar Gadewar

    Member
    August 11, 2016 at 5:45 pm

    Thanks Abhinav,

     

    It's very helpful !

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos