TChart.SeriesList.Add(..) vs. TChart.AddSeries(..)
Posted: Thu Sep 18, 2014 8:45 am
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:
I only found the quote
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.
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.