Page 1 of 1

Getting Series Title from SeriesList

Posted: Sun Feb 15, 2009 4:28 pm
by 9337074
I am using Delphi 2006 Professional with Teechart Pro 7.12. I have a dbChart filled with lines series. I want determine the series already existing in a chart. It is an easy thing but I am having trouble finding out to do that well. What I would like is the get the title and index and then replace it with new information. I am using the code below but I get a null exception and can't see why. Can someone steer me to the right way to do this? Thanks

//This code adds the aggregation series to the aggregation chart.
var
intList2: integer;
intSeriesList1: integer;
intOldSeriesIndx: Integer;
tmpChartSeries: TChartSeries;
begin
//try
//This code determines if series already exist. If they do then it looks for a series with the same name it wants to add. If found it removes the old series.
intOldSeriesIndx := -1;
if DBChart1.SeriesList.Count > 0 then
begin
tmpChartSeries := TChartSeries.Create(Self);
for intSeriesList1 := 1 to DBChart1.SeriesList.Count do
begin


if DBChart1.Series[intSeriesList1].Title = strSubModel + ' ' + strSeriesName then
begin

intOldSeriesIndx := intSeriesList1;
end;

end;
tmpChartSeries.Free;

if intOldSeriesIndx > -1 then
begin
DBChart1.RemoveSeries(intOldSeriesIndx);
end;
end;
end;

Posted: Mon Feb 16, 2009 12:06 pm
by yeray
Hi McMClark,

The series list is an array of series, and the arrays' indexes in delphi start at 0. So your for should be as follows:

Code: Select all

for intSeriesList1 := 0 to DBChart1.SeriesList.Count -1 do 
I hope it helps.

Posted: Mon Feb 16, 2009 1:19 pm
by 9337074
Thanks