FusionWidgets and Flash > Loading external XML Data |
In our previous examples, we had seen how to build XML data in a string variable using concatenation and then provide it to the chart. However, often you'll feel the need to load external XML data and then provide it to chart. However, FusionWidgets chart doesn't directly accept path to the XML file. As such, you'll need to load the XML data in your code and then pass the XML object to the chart. Here, we'll see an example. |
An example |
For this example, we first create a physical XML file named as MyData.xml and store the following data in this. We'll use this data to plot an angular gauge: |
<chart showBorder='0' bgColor='FFFFFF' lowerLimit='0' upperLimit='100' lowerLimitDisplay='Bad' upperLimitDisplay='Good' gaugeStartAngle='180' gaugeEndAngle='0' palette='1' numberSuffix='%' tickValueDistance='20' showValue='1'> <colorRange> <color minValue='0' maxValue='75' code='FF654F'/> <color minValue='75' maxValue='90' code='F6BD0F'/> <color minValue='90' maxValue='100' code='8BBA00'/> </colorRange> <dials> <dial value='92' rearExtension='10'/> </dials> </chart> |
Now, we create ExternalData.fla in the same folder. It contains the background and other setup like MyFirstChart.fla. We just change the code present in Actions layer to: |
/* //Import the required chart class. // ------------- Load XML Data for the chart -------------- // //createChart method is called when XML has loaded |
In the above code, we're:
As you can see, the only basic difference is that, here you're loading the XML in your objects and then providing it to the chart. When you now compile the file, you'll get similar results. |
Next, we'll see how to use the APIs exposed by chart. |