0 Replies Latest reply on May 29, 2008 2:26 PM by Solerous

    multiple chart axes with different scale

    Solerous Level 1
      I'm making a chart with two axes. The values are on completely different scales. One is from 0-600. The other is from 0-12. I can get the axes to look right but the actual plotting is messed up. The 0-12 axes is plotting based on the 0-600 scale so all the points are very close to the bottom axis. How do you define two different scales? I have to do it in actionscript and here is a sample of the code:


      public function makeChart(genericChart:CartesianChart,
      genericLegend:Legend, dynaChart:Panel, chart:ChartObject):void {

      var axisList:ArrayCollection = chart.getAxisList();
      var renderers:ArrayCollection = new ArrayCollection();
      var seriesArray:ArrayCollection = new ArrayCollection();
      for (var i:int=0; i<axisList.length; i++) {
      var axis:AxisObject = axisList.getItemAt(i) as AxisObject;

      // horizontal axis
      if (axis.getID() == "x Axis") {
      var hAxis:DateTimeAxis = new DateTimeAxis();
      var dMin:Date = axis.start;
      var dMax:Date = axis.end;
      if (dMax == null) dMax = new Date();
      hAxis.labelFunction = dateLabelFunction;
      hAxis.dataUnits = "days";

      // more formating of the horizontal axis
      var ar:AxisRenderer = new AxisRenderer();
      ar.axis = hAxis;
      ar.placement = "bottom";
      genericChart.horizontalAxisRenderers = [ar];
      genericChart.horizontalAxis = hAxis;
      }
      else {

      // Define vertical axis
      var vAxis:LinearAxis = new LinearAxis();
      vAxis.labelFunction = formatVertLabel;
      vAxis.title = axis.title;

      ////////////////////////////////////// AXIS scale defined
      vAxis.minimum = axis.min;
      vAxis.maximum = axis.max;
      //////////////////////////////////////

      if (axis.getID() == "y1 Axis") {
      genericChart.verticalAxis = vAxis;
      }
      else {
      placement = "right";
      }

      // define series
      var lineSeries:LineSeries = new LineSeries();
      BindingUtils.bindProperty(lineSeries, "dataProvider", axis, "points");
      lineSeries.displayName = axis.title;
      lineSeries.xField="point1";
      lineSeries.yField="point2";
      seriesArray.addItem(lineSeries);

      // more formatting of the axis
      var axr:AxisRenderer = new AxisRenderer();
      axr.axis = vAxis;
      axr.setStyle("color", stroke.color);
      axr.placement = placement;
      axr.setStyle("canDropLabels", "true");
      renderers.addItem(axr);
      }
      }
      // reverse so Y1 goes on top
      genericChart.series = seriesArray.toArray().reverse();
      genericChart.verticalAxisRenderers = renderers.toArray().reverse();
      genericChart.seriesFilters = [];
      genericLegend.dataProvider = genericChart;
      dynaChart.addChild(genericChart);
      dynaChart.addChild(genericLegend);
      this.addChild(dynaChart);
      }