Pie/Doughnut Chart - JavaScript API |
Pie 3D, Pie 2D, Doughnut 3D and Doughnut 2D charts expose a special function for better interactivity. Shown below is a table which contains detailed description of the function: |
Usage Example: |
Given below is are examples of how to use the function using JavaScript. togglePieSlice() |
<html> <head> <title>Pie/Doughnut slicing API</title> <script type="text/javascript" SRC="../../../Charts/FusionCharts.js"></script> <script type="text/javascript"> function slicePie() { // get the index of the slice to toggle slice = document.getElementById('index').value ; // toggle the slice FusionCharts("myChartId").togglePieSlice(slice); } </script> </head> <body> <div id="chartContainer">FusionCharts</div> <script language="JavaScript"> var myChart = new FusionCharts("../../../Charts/Pie3D.swf", "myChartId", "400", "300", "0", "1"); myChart.setXMLUrl("Data.xml"); myChart.render("chartContainer"); </script> <input type="text" id="index" size="5" value="0"/> <input type="button" value="Toggle" onclick="slicePie()"/> </body> </html> In the above code, we have created a Pie 3D chart with four slices. We have created a text input button to take pie slice index value as input. When a number is provided in the input box and Toggle button is clicked, togglePieSlice function is called. The slice id is passed to the function. In effect, the desired slice slices-out or slices-in. See it live! |