Hi Jonathan, 

I implemented your architecture below (using s.dataProvider instead of 
s.dataField) and adding some code before and after it as follows:

// from: http://tjoadesign.nl/blog/?p=334
for each ( var lineSeries:LineSeries in chart.series )  
    lineSeries.dataFunction = null ; // note: this appears to null here by 
default anyway

-- start Jonathan's code---

var i:int = -1; 
var n:int = yourData.length; 
var genLineSeries:Array = []; 
while(++i<n) { 
var s:LineSeries = new LineSeries(); 
   //add properties as necessary to series 
   s.dataProvider = yourData[i].dataField; 
   genLineSeries.push(s); 
} 
chart.series = genLineSeries; 

-- end Jonathan's code---

chart.invalidateDisplayList();


Now there's a memory leak seen using Flash Builder profiler each time I toggle 
between two different plots. The memory occupied by LineSeries increases every 
time a plot (new, or old) is generated, forever.  

Is there something that needs to be reset or initialized somewhere? 


----- Original Message ----- 
From: "Jonathan Campos" <[email protected]> 
To: "users" <[email protected]> 
Sent: Thursday, April 18, 2013 8:45:22 AM 
Subject: Re: how to dynamically add multiple LineSeries to a chart? 

On Wed, Apr 17, 2013 at 12:04 PM, <[email protected]> wrote: 

> Please set me straight how to dynamically add LineSeries the proper way. 
> Thanks for any help/advice. 


It's actually much easier than you are even doing it, pseudo code to follow: 

//loop your data describing the series that will be created 
var i:int = -1; 
var n:int = yourData.length; 
var genLineSeries:Array = []; 
while(++i<n) 
{ 
var s:LineSeries = new LineSeries(); 
//add properties as necessary to series 
//based on your data 
s.dataField = yourData[i].dataField; 
genLineSeries.push(s); 
} 
//assuming your chart 
lineChart.series = genLineSeries; 

//done 



-- 
Jonathan Campos 

Reply via email to