Exception in TChartseries.GetValueColor
Posted: Wed Nov 19, 2008 10:39 am
When I add several points to a TLineseries and afterwards call Chart1.Refresh, it runs into an endless loop of exceptions:
EListError: List index out of bounds (-1). The exception occurs in TeEngine.pas in "TChartSeries.GetValueColor", where Internalcolor(ValueIndex) is called.
I use several TLineseries in this chart, and I set "Coloreach" to true and added points using AddXY with different colors. As this old project is kind of really big, it's difficult to provide an example project ... And I was not able to reproduce the error in a new project.
However, it does not occur if AddXY is only used without a parameter for "aColor".
Further investigation showed that the Problem is in Line 2172 of Series.pas:
if IsNull(ValueIndex-1) then { if null }
When FColor is assigned (which is only when a Series has colors different from clTeeColor) and ValueIndex=0, this function tries to get an item with index -1 in the list which is not accessible.
Edit:
As a bugfix, I changed the above line to
if IsNull(ValueIndex) then { if null }
is this the right solution?
EListError: List index out of bounds (-1). The exception occurs in TeEngine.pas in "TChartSeries.GetValueColor", where Internalcolor(ValueIndex) is called.
I use several TLineseries in this chart, and I set "Coloreach" to true and added points using AddXY with different colors. As this old project is kind of really big, it's difficult to provide an example project ... And I was not able to reproduce the error in a new project.
However, it does not occur if AddXY is only used without a parameter for "aColor".
Further investigation showed that the Problem is in Line 2172 of Series.pas:
if IsNull(ValueIndex-1) then { if null }
When FColor is assigned (which is only when a Series has colors different from clTeeColor) and ValueIndex=0, this function tries to get an item with index -1 in the list which is not accessible.
Edit:
As a bugfix, I changed the above line to
if IsNull(ValueIndex) then { if null }
is this the right solution?