2 Replies Latest reply on May 16, 2007 9:25 AM by John_Milton

    Adding series to chart at runtime?

    John_Milton Level 1
      Newbie :-)

      I'm trying to add series to a chart at runtime becuase the number of series to plot is variable and only determined once the XML from an HTTPService comes back...

      My chart looks like this :

      <mx:PlotChart id="mainChart" showDataTips="true" width="100%" height="100%">

      If I add :

      <mx:PlotSeries xField="Size" yField="CompetitorPrice" displayName="Competitor Prices" />

      then the data plots OK, but trying to create the same series in AS doesn't work (nothing displayed) :

      var newSeries:PlotSeries = new PlotSeries();
      newSeries.xField = "Size";
      newSeries.yField = "CompetitorPrice";
      newSeries.displayName = "SeriesAddedAtRuntime!";

      Debugging shows the new series being added and it looks OK... but it doesn't display on the chart. No errors.

      I've tried mainChart.executeBindings(); and mainChart.validateNow(); without any luck but I'm guessing as to what needs to be happening here as you can probably tell!

      What am I missing something to force an update of the chart with the new series added??

      Thanks in advance