0 Replies Latest reply on May 27, 2007 2:29 PM by romanczar

    LineChart with unknown amount and name of elements

    romanczar Level 1
      I want to create a LineChart. This charts displays a changing number over a period of time.

      <?xml version="1.0" encoding="utf-8"?>
      <entry date="03/01/2007">
      <entry date="03/02/2007">
      <entry date="03/03/2007">

      <mx:LineChart id="chart" dataProvider="{service.lastResult.root.poll.resultsByDate.entry}" >
      <mx:CategoryAxis categoryField="date" />
      <mx:AxisRenderer labelRotation="45" />
      <mx:LineSeries displayName="1" xField="date" yField="results" />
      <mx:LineSeries displayName="2" xField="date" yField="results" />

      It only works when I don't use <results> in the XML and set the yField to "1" or "2".

      Later In the application I don't know the amount and name of the elements (1,2,44,4564, ..), so I will use AS for that:

      var ls:LineSeries = new LineSeries();
      chart.series = [ls]; // associate the array

      var answers:Array = ["1", "2"];

      for (var i:uint = 0; i < 2; i++)
      ls = new LineSeries();
      ls.displayName = answers .toString()
      ls.xField = 'date';
      ls.yField = 'results';
      = ls;

      This code works, but only without 'results'.

      Maybe can someone help me? I sit not possible to have nested objects as provider for xField and yField?