Drag-node Chart > Reading data using JavaScript |
In our previous section, we had seen how to submit the updated data from chart to a server side script as form elements. Here, we'll see how to read the updated data using JavaScript functions present on the same page. |
| Enabling JavaScript access to the chart |
| To enable JavaScript access to your chart, you first need to set the registerWithJS flag of the chart to 1. |
| <div id="chartdiv" align="center">
FusionCharts. </div> <script type="text/javascript"> var chart = new FusionCharts("DragNode.swf", "NodeChart", "580", "350", "0", "1"); chart.setDataURL("Data.xml"); chart.render("chartdiv"); </script> |
Notice the last parameter in chart constructor function - it's set to 1. The above code renders a chart in the page with data from Data.xml. We wouldn't actually focus on data here, as we're trying to link this data to JavaScript and not build it. XML data structrue for the chart can be seen in Chart XML Sheet section. Now that the chart is rendered, whenever we need access to chart's data as XML, we can simple call the following function on the chart: |
//Get a reference to our chart |