1 Reply Latest reply on Jan 9, 2008 8:09 AM by Deeptika Gottipati

    Programmatically adding series to a chart

    tduffey
      Hi,

      Does anyone have a good example of how to programmatically add one or more series to a chart? I have a column chart that always has at least one column series but depending on user input can have several more. The code I wrote to create a new ColumnSeries and add it to the chart's series array compiles but the chart never displays the additional series'.

      Any thoughts? The code looks something like this:
        • 1. Re: Programmatically adding series to a chart
          Deeptika Gottipati Adobe Employee
          Please try this code snippet

          var cs:ColumnSeries = new ColumnSeries();
          cs.dataProvider = dp;
          cs.displayName = "Series 2";
          cs.yField = "values";
          chart.series.push(cs);

          OR


          var temp:Array = [];
          var cs:ColumnSeries = new ColumnSeries();
          cs.dataProvider = dp;
          cs.displayName = "Series 2";
          cs.yField = "values";
          temp = chart.series;
          temp.add(cs);
          chart.series = temp;