TAChart: improper calculations in TChart.YImageToGraph
Original Reporter info from Mantis: Marcin Wiazowski
-
Reporter name:
Original Reporter info from Mantis: Marcin Wiazowski
- Reporter name:
Description:
Problem described here is related to #34819 (closed), but has been described separately here, to avoid mess in the original report.
In TAGraph.pas, there are two functions declared:
function TChart.XImageToGraph(AX: Integer): Double;
begin
if AX >= MAX_COORD then
Result := Infinity * SgnInt(FScale.X)
else if AX <= -MAX_COORD then
Result := -Infinity * SgnInt(FScale.X)
else
Result := (AX - FOffset.X) / FScale.X;
end;
function TChart.YImageToGraph(AY: Integer): Double;
begin
if AY >= MAX_COORD then
Result := Infinity * SgnInt(FScale.Y)
else if AY <= -MAX_COORD then
Result := +Infinity * SgnInt(FScale.Y)
else
Result := (AY - FOffset.Y) / FScale.Y;
end;
The idea is:
- for very large, positive values, return +INF,
- for very large, negative values, return -INF,
- in other cases perfrom the calculations.
There is a mistake in TChart.YImageToGraph: "+Infinity" should be changed to "-Infinity".
Regards