function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
YashYash 

Generated the pie chart in VF page using plotkit

Hi,
 
I am able to generate the pie chart in visual force page using plotkit.
 
 
 
Code:
<apex:page >
        <apex:includeScript value="{!URLFOR($Resource.mochikit_1_3_1_zip,'/MochiKit-1.3.1/lib/MochiKit/MochiKit.js')}"/>
        <apex:includeScript value="{!URLFOR($Resource.plotkit_0_9_1_zip,'/plotkit-0.9.1/PlotKit/Base.js')}"/>
        <apex:includeScript value="{!URLFOR($Resource.plotkit_0_9_1_zip,'/plotkit-0.9.1/PlotKit/Layout.js')}"/>
        <apex:includeScript value="{!URLFOR($Resource.plotkit_0_9_1_zip,'/plotkit-0.9.1/PlotKit/Canvas.js')}"/>
        <apex:includeScript value="{!URLFOR($Resource.plotkit_0_9_1_zip,'/plotkit-0.9.1/PlotKit/SweetCanvas.js')}"/>
        <div><canvas id="graph" height="300" width="300">Graph</canvas></div>
        <script type="text/javascript">
            function drawGraph(){
                var options={"IECanvasHTC": "/plotkit/iecanvas.htc",
                    "colorScheme": PlotKit.Base.palette(PlotKit.Base.baseColors()[0]),
                    "padding": {left: 0, right: 0, top: 10, bottom: 30},
                    "xTicks": [ {v:0,label:"ZERO"},{v:1,label:"ONE"},{v:2,label:"TWO"},{v:3,label:"THREE"},{v:4,label:"FOUR"}],
                    "drawYAxis": false};
                var layout = new PlotKit.Layout("pie", options);
                layout.addDataset("sqrt", [[0, 0], [1, 1], [2, 1.414], [3, 1.73], [4, 2]]);
                layout.evaluate();
                var canvas = MochiKit.DOM.getElement("graph");
                var plotter = new PlotKit.SweetCanvasRenderer(canvas, layout, options);
                plotter.render();
            }
            MochiKit.DOM.addLoadEvent(drawGraph);
        </script>
</apex:page>

 
Thanks
Yash
YashYash

Hi,

The above code is not working in IE. So we have to include the 'excanvas.js' script file.

<apex:includeScript value="{!URLFOR($Resource.plotkit_0_9_1_zip,'/plotkit-0.9.1/PlotKit/excanvas.js')}"/>

Thanks.

Yash

YashYash
HI,
 
I want to add the 'Legends' to the above generated graph. Can we do it in VF page and if yes what are the libraries used to do that?
 
Thanks
Yash