1 Reply Latest reply on Aug 1, 2007 11:19 AM by saliksyed

    Adding a dynamoically named property to object

    saliksyed
      I am building a graph display application.
      The user inputs a data url via javascript/forms ... the flex app gets the xml url.
      What I want is to have a single line chart, and add series at run time based on user input.
      I want to show the previous graphs as well. The problem is that the chart is limited to a single data provider.
      How do I add more series data to a single data provider?
      This is my curr method:

      var myData:XML = new XML(event.target.data);

      for (var i:Number = 0; i <myData.samples.reading.length(); i++) // myData is the new data
      {
      var point:Object = dataSet.getItemAt(i); // get the previous line chart data
      // the idea (which doesn't work) is to add a field to the point Object that has the new point:

      point["value"+currSeriesIndex] = myData.samples.reading ;
      // I am a noob at actionscript (what is the proper syntax the above compiles but doesn't work)
      }
      // Now create a new line series
      var newSeries:LineSeries = new LineSeries();
      newSeries.interactive=true;
      newSeries.dataProvider = dataSet;
      newSeries.yField="value"+currSeriesIndex; // set the yField
      // this is to add the new Series to the line chart (should this work???)
      linechart1.addChild(newSeries);
      // increment
      currSeriesIndex++;
      Alert.show("added graph");