Page 1 of 1

Remove Series from chart without freeing that same series

Posted: Thu Oct 30, 2008 7:17 pm
by 10548769
Hi

I have some objetcs that have Series in it. Because i need to used them on multiple charts. When i delete them from a chart, it free it at the same time but i need to keep it. So how can i bypass that. Maybe im not doing it right to add/delete them so this is my simple code.

Adding

Code: Select all

MyObject.MySerie := TLineSeries.Create(Nil); //Nil as Owner should mean -> i will free it Myself.
//Populate my serie
Chart.AddSeries(MyObject.MySerie);
Deleting

Code: Select all

Chart.SeriesList.Clear;
When i use Clear, it clear all series but free them too.

Posted: Thu Oct 30, 2008 7:43 pm
by 10548769
ok i found why its freeing them.

Have to change ParentChart to Nil so it wont be deleted, btw you should check the owner for freeing them and not the parent. This goes againts the VCL standard.

Posted: Fri Oct 31, 2008 8:28 am
by narcis
Hi GoToXY,

To remove chart series without freeing them you can use Chart1.RemoveAllSeries. Anyway, I'll add your suggestion to the list to be investigated for next releases.