Getting Series Title from SeriesList
Posted: 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;
//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;