1 Reply Latest reply on Sep 26, 2008 7:40 AM by Newsgroup_User

    Dynamic chart dataproviders

    Cr99 Level 1
      It's very easy to definie charts in mxml, but in actionscript I am wondering how I could define a dynamic, unbounded arraycollection to be the dataprovider for a chart. For example, in mxml you might have the code from below, but what if you don't know at runtime, how many series you will have in your chart?

      I could do something like this in a for loop:

      genericChart.dataProvider = myData; // myData is a generic ArrayCollection
      // for loop start
      var seriesList:ArrayCollection=new ArrayCollection();
      var columnSeries:ColumnSeries = new ColumnSeries();
      columnSeries.xField="point1"; // problem
      columnSeries.yField="point2"; // problem
      // for loop end, then assign series to chart
      genericChart.series = seriesList.toArray();

      but labeling the xField and yField are a problem since I don't know the names of them in a dynamically created Arraycollection. Any idea on how to make this work?