0 Replies Latest reply on Jun 23, 2006 6:31 AM by FrankAtcomm

    convert xml webservice result to series for chart

    FrankAtcomm
      Hello,

      I want these data to be shown in a chart...

      <resultlist>
      <result>
      <ShowMonth>1</ShowMonth>
      <YearFields>
      <2003>967,13</2003>
      <2004>2703,31</2004>
      <2005>5517,5</2005>
      <2006>1297,6</2006>
      </YearFields>
      </result>
      <result>
      <ShowMonth>2</ShowMonth>
      <YearFields>
      <2003>3149,03</2003>
      <2004>4802,51</2004>
      <2005>4851,18</2005>
      <2006>16290,04</2006>
      </YearFields>
      </result>
      ...

      I already have a function to convert the xml result into a dataprovider, maybe I just have to add a few lines here ?

      private function FillMonthTotal():void {
      var x:XML = new XML(WsMonthTotal.WsMonthTotal.lastResult);

      showErrorDialog(x.children());

      salesChart.dataProvider = new XMLListCollection(x.children());
      salesChart.series.
      }

      I was trying with this mxml, but only get the horizontalAxis to work. How do I get the values of YearFields (for 2003, 2004, ...) to be shown as different areas on the chart dynamically, so it doesn't has to be changed in the code every year ?

      <mx:AreaChart id="salesChart" width="300" height="300">
      <mx:horizontalAxis>
      <mx:CategoryAxis categoryField="ShowMonth"/>
      </mx:horizontalAxis>
      <!--<mx:series>
      <mx:Array>
      <mx:ColumnSeries xField="ShowMonth" yField="2003" displayName="2003"/>
      <mx:ColumnSeries xField="ShowMonth" yField="2004" displayName="2004"/>
      <mx:ColumnSeries xField="ShowMonth" yField="2005" displayName="2005"/>
      <mx:ColumnSeries xField="ShowMonth" yField="2006" displayName="2006"/>
      </mx:Array>
      </mx:series> -->
      </mx:AreaChart>

      Thanks a lot for any help or suggestions ...
      Frank