Search Tutorials
Getting data into the chartThe functions layer will contain the LoadChartData function. This function will load the XML data into the chart component. The chart will be referenced by using the instance name MyChart. The first thing to do is create the function on the functions layer and set up a reference for the chart node in the XML document.
function LoadChartData() {
We will use the BaseNode to reference other nodes within the XML document. The chart data is contained in the child nodes of the base node. These are the chartItem nodes. The following code loads the label and values for each chart item into an array and then adds them to the ChartData data source. I chose the names DataLabel and DataValue for the fieldnames in the data source.
//set up arrays Note: You don't have to load the chart labels and
values into an array first, but it might be useful if you're going to use
the information in some other way.
The next step is to link the datasource to the MyChart object and indicate
which fields contain the labels and values. MyChart.setDataProvider(ChartData); Test the movie and you should see a chart populated with the values from your XML file. The complete code for the functions frame is on the next page.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
|||||||||||||||||||||||||||||||||||||||||||||||||||
|