Getting Series Title from SeriesList

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
McMClark
Newbie
Newbie
Posts: 50
Joined: Thu Apr 15, 2004 4:00 am

Getting Series Title from SeriesList

Post by McMClark » Sun Feb 15, 2009 4:28 pm

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;

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Post by Yeray » Mon Feb 16, 2009 12:06 pm

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.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

McMClark
Newbie
Newbie
Posts: 50
Joined: Thu Apr 15, 2004 4:00 am

Post by McMClark » Mon Feb 16, 2009 1:19 pm

Thanks

Post Reply