1 Reply Latest reply on Mar 22, 2011 2:39 AM by Tanu Jain

    XML as dataProvider for Charts

    Arul pugazh

           I want to display XML exported from Oracle Database as a chart......

       

      The xml has the following structure :

       

      <ROWSET>

            <ROW>

                  <ORDER_ITEMS_ID>1</ORDER_ITEMS_ID>

                  <ORDER_ID>1</ORDER_ID>

                  <PRODUCT_ID>1</PRODUCT_ID>

                  <UNIT_PRICE>1200</UNIT_PRICE>

                  <QUANTITY>1</QUANTITY>

            </ROW>

            <ROW>

                  <ORDER_ITEMS_ID>2</ORDER_ITEMS_ID>

                  <ORDER_ID>7</ORDER_ID>

                  <PRODUCT_ID>1</PRODUCT_ID>

                  <UNIT_PRICE>1100</UNIT_PRICE>

                  <QUANTITY>3</QUANTITY>

            </ROW>

      </ROWSET>

       

      I've seen many chart examples using ArrayCollection as DataProvider . using the same way , i tried to set xml . But no results.

       

      Can you please suggest me how to set an XML as dataprovider ? ( or XMLList or XMLlistcollection )

       

      ( i'm developing a small app in AIR )

        • 1. Re: XML as dataProvider for Charts
          Tanu Jain Level 2

          Sample app from Adobe's livedocs:

           

          XML:

          <data>
              <result month="Jan-04">
                  <apple>81768</apple>
                  <orange>60310</orange>
                  <banana>43357</banana>
              </result>
              <result month="Feb-04">
                  <apple>81156</apple>
                  <orange>58883</orange>
                  <banana>49280</banana>
              </result>
          </data>
          

           

          Application:

          <?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:horizontalAxis>
                     <mx:CategoryAxis categoryField="month"/>
                  </mx:horizontalAxis>
                  <mx:series>
                     <mx:LineSeries yField="banana" displayName="Banana"/>
                     <mx:LineSeries yField="apple" displayName="Apple"/>
                     <mx:LineSeries yField="orange" displayName="Orange"/>
                  </mx:series>
               </mx:LineChart>
               <mx:Legend dataProvider="{myChart}"/>     
            </mx:Panel>
          </mx:Application>
          

          --
          Tanu