Page 1 of 1

TChart.SeriesList.Add(..) vs. TChart.AddSeries(..)

Posted: Thu Sep 18, 2014 8:45 am
by 16567885
I have a feeling that something this obvious is somewhere in the documentation but I can't find anything.

How would one go about adding a TChartSeries at runtime? Please have a look at this:

Code: Select all

implementation uses VclTee.Series;
{$R *.dfm}

procedure TForm3.Button1Click(Sender: TObject);
var
	newSeries:  TChartSeries;
begin
	newSeries := TLineSeries.Create(chart1);
	newSeries.FillSampleValues();

	(* this is bad:
	newSeries.ParentChart := chart1;
	Chart1.SeriesList.Add(newSeries) *)

	// this is good
	Chart1.AddSeries(newSeries);
end;
I only found the quote
Warning: Never FREE or REMOVE SeriesList elements. Use the Series.Free to remove it or use the Series.Active property to disable it.
on the documentation for TCustomAxisPanel.SeriesList

My question is: Why?
So if I want to add a TChartSeries, always use the chart directly, not the SeriesList? If yes, then why does the TSeriesList even expose Methods like Add() in the first place?


Many thanks in advance.

Re: TChart.SeriesList.Add(..) vs. TChart.AddSeries(..)

Posted: Thu Sep 18, 2014 11:59 am
by yeray
Hello,

I think it's public just to preserve the backwards compatibility.