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;
on the documentation for TCustomAxisPanel.SeriesListWarning: Never FREE or REMOVE SeriesList elements. Use the Series.Free to remove it or use the Series.Active property to disable it.
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.