1 Reply Latest reply on Jan 29, 2009 1:46 PM by G009

    Charts in Actionscript

      Hello guys,
      I am trying to create chart in Flex. I have two xmls. One contain header information. And using that header information i want to access other xml file. I believe my logic is right. I managed to implement it in actionscript. But am not sure whatever i did is right or not. I am uploading my mxml. When i try to run it nothing get loaded in browser. And i get network timout error. Here is my code.

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" height="600" creationComplete="create()">
      <mx:HTTPService id="header" url="header.do" showBusyCursor="true" result="xmlheaderHandler(event)" resultFormat="e4x"/>
      <mx:HTTPService id="data" url="test.do" showBusyCursor="true" result="xmlHandler(event)" resultFormat="e4x"/>

      import mx.collections.ArrayCollection;
      import mx.charts.ColumnChart;
      import mx.charts.series.ColumnSeries;
      import mx.charts.CategoryAxis;
      import mx.charts.Legend;
      import mx.rpc.events.ResultEvent;
      import mx.controls.dataGridClasses.DataGridColumn;
      import mx.controls.DataGrid;
      import mx.collections.XMLListCollection;
      import mx.controls.Alert;

      private function create():void{


      //XML List for loaded XML file. Must be bindable!
      [Bindable]private var headerInfo:XMLList;
      [Bindable]private var testInfo:XMLList;

      private function xmlheaderHandler(evt:ResultEvent):void{
      //Sets testInfo's root as the student. Everything else referenced in respect to this.
      headerInfo = evt.result.COLUMN;

      private function xmlHandler(evt:ResultEvent):void{
      //Sets testInfo's root as the student. Everything else referenced in respect to this.
      testInfo = evt.result.VALUES;

      public var myChart:ColumnChart;
      public var series1:ColumnSeries;
      public var legend1:Legend;
      public var ids:Array;
      public var values:Array;

      public function init():void {
      var i:int;
      var max:int;

      max = headerInfo.child("COUNT");

      ids = headerInfo.child("ID");
      values = headerInfo.child("VALUES");

      // Create the chart object and set some
      myChart = new ColumnChart();
      myChart.showDataTips = true;
      myChart.dataProvider = testInfo;

      // Define the category axis.
      var hAxis:CategoryAxis = new CategoryAxis();
      //Loop can come here
      hAxis.categoryField = ids[0] ;
      hAxis.dataProvider = testInfo;
      myChart.horizontalAxis = hAxis;

      // Add the series.
      var mySeries:Array=new Array();
      series1 = new ColumnSeries();
      //Loop can come here
      series1.displayName = "Profit";
      myChart.series = mySeries;

      // Create a legend.
      legend1 = new Legend();
      legend1.dataProvider = myChart;

      // Attach chart and legend to the display list.




      <mx:Panel id="p1" title="Bar Chart Created in ActionScript"/>


      Thanks in advance