2 Replies Latest reply on Oct 16, 2009 3:41 AM by anuroop99

    Setting x axis and yaxis value of Line Chart in action script

    anuroop99

      Dear All

       

                 I need to set X axis and y axis value of Line chart in action script.i search in web for a day .i couldnt get any result in the web , any one have solution please give me.i have code of mxml

       

       

       

       

       

      <mx:horizontalAxis

      >

       

       

       

      <mx:LinearAxis minimum="10" interval="5" maximum="100"

      />

       

       

       

       

      </mx:horizontalAxis>

       

      <mx:verticalAxis>

       

      <mx:LinearAxis minimum="30" maximum="50"/>

       

      </mx:verticalAxis>

       

      Thanks And Regards

      Anuroop Vincent

        • 1. Re: Setting x axis and yaxis value of Line Chart in action script
          EgorKDie Level 2

          Lucky for you I was just in the process of documenting this bad boy!

           

          public function draw( contentArea : DisplayObjectContainer, dataSet : ListCollectionView ) : void {
                      var axis : CategoryAxis = new CategoryAxis();
                      axis.categoryField = xAttribute;
                      axis.labelFunction = labFunc;
                     
                      var axisRenderer : AxisRenderer = new AxisRenderer();
                      axisRenderer.axis = axis;
                      axisRenderer.setStyle( "labelRotation", 0 );
                     
                      var series : ColumnSeries = new ColumnSeries();
                      series.yField = yAttributes[0];
                      series.minField = yAttributes[1];
                     
                      var sort : Sort = new Sort();
                      sort.compareFunction = compFunc;
                      sort.fields = [ new SortField( xAttribute, true ) ];
                      var collection : ListCollectionView = new ListCollectionView( dataSet );
                      collection.sort = sort;
                      collection.refresh();
                     
                      var graph : ColumnChart = new ColumnChart();
                      graph.percentHeight = 100;
                      graph.percentWidth = 100;
                      graph.showDataTips = true;
                      graph.series = [series];
                      graph.horizontalAxis = axis;
                      graph.dataProvider = collection;
                      graph.setStyle( "columnWidthRatio", 0.1 );
                     
                      contentArea.addChild( graph );
                  }

          • 2. Re: Setting x axis and yaxis value of Line Chart in action script
            anuroop99 Level 1

            Thank you my dear fried.it will helps me a lot