1 Reply Latest reply on Apr 5, 2010 11:24 PM by EladEladElad111

    Line Charts with fusion charts XML

    EladEladElad111

      Hi all,

       

      I have an fusion charts XML and I want to use it to make a graph using flex charts (the line charts).

      I use a web service to get the XML and I put the result in an array collection (Bindable variable):

       

      private function graphItNow(event:ResultEvent):void{
                      xmlGraph = event.result as ArrayCollection;

      }

       

      Here is the XML:

       

      <chart animation='0' caption='f' lineThickness='2' 
           showValues
      ='1' areaOverColumns='0' formatNumberScale='0'
                useRoundEdges
      ='1' palette='2' legendBorderAlpha='0'>
      <categories>
      <category label='00:00' />
      <category label='01:00' />
      <category label='02:00' />
      <category label='03:00' />
      <category label='04:00' />
      <category label='05:00' />
      <category label='06:00' />
      <category label='07:00' />
      <category label='08:00' />
      <category label='09:00' />
      <category label='10:00' />
      <category label='11:00' />
      <category label='12:00' />
      <category label='13:00' />
      <category label='14:00' />
      <category label='15:00' />
      <category label='16:00' />
      <category label='17:00' />
      <category label='18:00' />
      <category label='19:00' />
      <category label='20:00' />
      <category label='21:00' />
      <category label='22:00' />
      <category label='23:00' />
      </categories>
      <dataset seriesName='netvision' renderAs='Line' lineThickness='2'>
      <set value='182' toolText='netvision' />
      <set value='181' toolText='netvision' />
      <set value='176' toolText='netvision' />
      <set value='182' toolText='netvision' />
      <set value='182' toolText='netvision' />
      <set value='181' toolText='netvision' />
      <set value='183' toolText='netvision' />
      <set value='181' toolText='netvision' />
      <set value='180' toolText='netvision' />
      <set value='181' toolText='netvision' />
      <set value='182' toolText='netvision' />
      <set value='181' toolText='netvision' />
      <set value='182' toolText='netvision' />
      <set value='180' toolText='netvision' />
      <set value='179' toolText='netvision' />
      <set value='181' toolText='netvision' />
      <set value='177' toolText='netvision' />
      <set value='167' toolText='netvision' />
      <set value='182' toolText='netvision' />
      <set value='180' toolText='netvision' />
      <set value='180' toolText='netvision' />
      <set value='180' toolText='netvision' />
      <set value='182' toolText='netvision' />
      <set value='171' toolText='netvision' />
      </dataset>
      <dataset seriesName='bezeqint' renderAs='Line' lineThickness='2'>
      <set value='162' toolText='bezeqint' />
      <set value='163' toolText='bezeqint' />
      <set value='170' toolText='bezeqint' />
      <set value='154' toolText='bezeqint' />
      <set value='160' toolText='bezeqint' />
      <set value='167' toolText='bezeqint' />
      <set value='155' toolText='bezeqint' />
      <set value='153' toolText='bezeqint' />
      <set value='151' toolText='bezeqint' />
      <set value='157' toolText='bezeqint' />
      <set value='159' toolText='bezeqint' />
      <set value='154' toolText='bezeqint' />
      <set value='174' toolText='bezeqint' />
      <set value='160' toolText='bezeqint' />
      <set value='146' toolText='bezeqint' />
      <set value='162' toolText='bezeqint' />
      <set value='152' toolText='bezeqint' />
      <set value='157' toolText='bezeqint' />
      <set value='162' toolText='bezeqint' />
      <set value='145' toolText='bezeqint' />
      <set value='166' toolText='bezeqint' />
      <set value='164' toolText='bezeqint' />
      <set value='155' toolText='bezeqint' />
      <set value='164' toolText='bezeqint' />
      </dataset>
      <dataset seriesName='012' renderAs='Line' lineThickness='2'>
      <set value='149' toolText='012' />
      <set value='156' toolText='012' />
      <set value='170' toolText='012' />
      <set value='171' toolText='012' />
      <set value='157' toolText='012' />
      <set value='163' toolText='012' />
      <set value='153' toolText='012' />
      <set value='153' toolText='012' />
      <set value='144' toolText='012' />
      <set value='162' toolText='012' />
      <set value='169' toolText='012' />
      <set value='165' toolText='012' />
      <set value='168' toolText='012' />
      <set value='151' toolText='012' />
      <set value='130' toolText='012' />
      <set value='133' toolText='012' />
      <set value='126' toolText='012' />
      <set value='137' toolText='012' />
      <set value='136' toolText='012' />
      <set value='130' toolText='012' />
      <set value='148' toolText='012' />
      <set value='132' toolText='012' />
      <set value='137' toolText='012' />
      <set value='166' toolText='012' />
      </dataset>
      <trendLines><line startValue='163' color='359A35' displayvalue='Good' valueOnRight='1' /></trendLines>
      </chart>

       

       

      As you can imagin, the horizontalAxis values need to have the values of:

           chart.categories.category.@label

      The Line Serias values supposed to be:

           chart.dataset.set.@value

           Each one with the relevant Display name of chart.dataset.@seriasName

       

      I've tried my best to make an action script to populate the chart with no luck.

      I've tried this trick also: http://www.devrecipes.com/2009/05/10/flex-chart-from-xml-data-using-httpservice-with-java- servlets/ still - nothing

       

      Can anyone guied me how to approch this kind of XML?

       

      Thanks,

      Elad

        • 1. Re: Line Charts with fusion charts XML
          EladEladElad111 Level 1

          Hi,

           

          Still Trying:

          I've now got this code to function:

           

          var i:int = 0;
                          for each (var cat:* in event.result.chart.categories.category){
                              //mx.controls.Alert.show(cat.label);
                              var z:int = 0;
                              for each (var valuee:* in event.result.chart.dataset){
                                  //mx.controls.Alert.show(event.result.chart.dataset[z].seriesName);
                                  //mx.controls.Alert.show(valuee.sete[i].value);
                                 
                                  z++;
                              }
                              i++

           

          which works fine, how can I get in into Array to make a dataset for the flex charts?

           

          Thanks,

          Elad