3 Replies Latest reply on Jul 18, 2008 4:15 PM by ntsiii

    External XML file for a chart

    ice1000 Level 1
      I'm new to Flex but using the samples & documentation, I have been able to create a simple chart that uses an external xml file for it's data source.

      I'm not sure how get to the next step, which is:
      Have the chart listen to any changes in the xml file and update itself at run time.

      Can anyone point me to samples or docs that can help me out?

        • 1. Re: External XML file for a chart
          SujitG Level 2

          How is the XML file going to be updated? Is the XML file going to be updated using the same application or some other application? When you said external XML file is it on the server or is it embed with SWF?

          You can also have a look at the Data Binding feature in Flex. Please find quick start guide on data binding at the URL below.


          Hope this helps.
          • 2. Re: External XML file for a chart
            ice1000 Level 1

            The XML file will be updated by another application. What I meant by external XML file was that I followed the steps in the documentation on using an xml file as a data provider:

            You can define data provider data in a structured file. The following example shows the contents of the data.xml file:
            <result month="Jan-04">
            <result month="Feb-04">
            You can load the file directly as a source of a Model, as the following example shows:
            <?xml version="1.0"?>
            <!-- charts/XMLFileDataProvider.mxml -->
            <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml">
            <mx:Model id="results" source="../assets/data.xml"/>
            <mx:Panel title="Line Chart">
            <mx:LineChart id="myChart" dataProvider="{results.result}" showDataTips="true">
            <mx:CategoryAxis categoryField="month"/>
            <mx:LineSeries yField="banana" displayName="Banana"/>
            <mx:LineSeries yField="apple" displayName="Apple"/>
            <mx:LineSeries yField="orange" displayName="Orange"/>
            <mx:Legend dataProvider="{myChart}"/>

            The xml file is on the server but not embedded. When I change the xml file, the swf does not update unless I recompile.

            I will read over the link you provided.

            Thanks for your help!
            • 3. Re: External XML file for a chart
              ntsiii Level 3
              source="path" is a *compile time* operation, so the xml is in fact embedded in the swf.

              If you want run-time loading, then use HTTPService.

              Also, do not use mx:Model, and if you use HTTPService, be sure to set resultFormat="e4x".

              Search the archives if you want to know why, and read more detail and examples.