1 Reply Latest reply on May 28, 2008 6:03 AM by Gregory Lafrance

    problem generating a chart with ActionScript

    ms10
      I am attempting to generate a simple Line Chart using Actionscript, but am unable to get it to draw out the data, even though it works ok when in mxml, or for that matter assinging the series with ActionScript to a chart defined with mxml.

      The key points of code are below, so if anyone can see where i'm going wrong, i'd be much grateful.


      <mx:Application creationComplete="onCreationComplete()" >
      <mx:Script>
      private function onCreationComplete():void
      {
      var linechart:LineChart = new LineChart();
      linechart.dataProvider = arr;

      var catAxis:CategoryAxis = new CategoryAxis();
      catAxis.dataProvider = arr;

      var lineSeries:LineSeries = new LineSeries();
      lineSeries.yField = "Profit";
      var arr:Array = new Array();
      arr.push(lineSeries);
      linechart.series = arr;

      hb5.addChild(linechart);
      }
      </mx:Script>
      <mx:Array id="arr">
      <mx:Object Country="UK" From="Phill" Subject="Subject1" SubjectMeta="34" Date="12/08/06" CC="Jim1" CCMeta="11" Profit="69" />
      <mx:Object Country="UK" From="Phill" Subject="Subject2" SubjectMeta="35" Date="12/08/06" CC="Jim2" CCMeta="48" Profit="48" />
      <mx:Object Country="UK" From="Harry" Subject="Subject3" SubjectMeta="36" Date="November 2, 2006" CC="Ram" CCMeta="28" Profit="11" />
      <mx:Object Country="Fr" From="Barb" Subject="Subject4" SubjectMeta="378" Date="12/08/06" CC="Anant" CCMeta="42" Profit="20" />
      <mx:Object Country="Fr" From="Amit" Subject="Subject5" SubjectMeta="343" Date="12/07/06" CC="Jim3" CCMeta="55" Profit="28" />
      <mx:Object Country="Fr" From="John" Subject="Subject6" SubjectMeta="341" Date="12/07/06" CC="Jim4" CCMeta="68" Profit="12" />
      <mx:Object Country="Fr" From="Amit" Subject="Subject7" SubjectMeta="345" Date="12/07/06" CC="Jim5" CCMeta="70" Profit="22" />
      <mx:Object Country="Fr" From="Amit" Subject="Subject8" SubjectMeta="342" Date="12/07/06" CC="Jim6" CCMeta="80" Profit="22" />
      </mx:Array>

      <mx:Panel title="Line chart" id="pnl">
      <mx:HBox height="400" id="hb5">
      </mx:HBox>
      </mx:Panel>

      </mx:Application>