mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-05 05:19:36 +01:00
TAChart: Fix AreaSeries drawing inverted area if it extends down to -Inf.
git-svn-id: trunk@60075 -
This commit is contained in:
parent
25e8ac68ed
commit
361e42f65a
@ -35,6 +35,10 @@ const
|
|||||||
DEFAULT_FONT_SIZE = 10;
|
DEFAULT_FONT_SIZE = 10;
|
||||||
DEFAULT_EPSILON = 1e-6;
|
DEFAULT_EPSILON = 1e-6;
|
||||||
|
|
||||||
|
// Replacement for +INF, Canvas does not work correctly when MaxInt is used.
|
||||||
|
// Any screen coordinates are clipped to range -MAX_COORD ... MAX_COORD.
|
||||||
|
MAX_COORD = 100*1000*1000;
|
||||||
|
|
||||||
type
|
type
|
||||||
EChartError = class(Exception);
|
EChartError = class(Exception);
|
||||||
EChartIntervalError = class(EChartError);
|
EChartIntervalError = class(EChartError);
|
||||||
@ -331,6 +335,7 @@ procedure Exchange(var A, B: String); overload; inline;
|
|||||||
function FormatIfNotEmpty(AFormat, AStr: String): String; inline;
|
function FormatIfNotEmpty(AFormat, AStr: String): String; inline;
|
||||||
|
|
||||||
function IfThen(ACond: Boolean; ATrue, AFalse: TObject): TObject; overload;
|
function IfThen(ACond: Boolean; ATrue, AFalse: TObject): TObject; overload;
|
||||||
|
function ImgRoundChecked(A: Double): Integer; inline;
|
||||||
function InterpolateRGB(AColor1, AColor2: Integer; ACoeff: Double): Integer;
|
function InterpolateRGB(AColor1, AColor2: Integer; ACoeff: Double): Integer;
|
||||||
function IntToColorHex(AColor: Integer): String; inline;
|
function IntToColorHex(AColor: Integer): String; inline;
|
||||||
function IsEquivalent(const A1, A2: Double): Boolean; inline;
|
function IsEquivalent(const A1, A2: Double): Boolean; inline;
|
||||||
@ -444,6 +449,11 @@ begin
|
|||||||
Result := AFalse;
|
Result := AFalse;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function ImgRoundChecked(A: Double): Integer;
|
||||||
|
begin
|
||||||
|
Result := Round(EnsureRange(A, -MAX_COORD, MAX_COORD));
|
||||||
|
end;
|
||||||
|
|
||||||
function InterpolateRGB(AColor1, AColor2: Integer; ACoeff: Double): Integer;
|
function InterpolateRGB(AColor1, AColor2: Integer; ACoeff: Double): Integer;
|
||||||
type
|
type
|
||||||
TBytes = packed array [1..4] of Byte;
|
TBytes = packed array [1..4] of Byte;
|
||||||
|
|||||||
@ -1856,24 +1856,41 @@ begin
|
|||||||
s.VisitSources(AVisitor, AAxis, AData);
|
s.VisitSources(AVisitor, AAxis, AData);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function SgnInt(X: Double): Integer;
|
||||||
|
begin
|
||||||
|
if X > 0 then Result := +1
|
||||||
|
else if X < 0 then Result := -1
|
||||||
|
else Result := 0;
|
||||||
|
end;
|
||||||
|
|
||||||
function TChart.XGraphToImage(AX: Double): Integer;
|
function TChart.XGraphToImage(AX: Double): Integer;
|
||||||
begin
|
begin
|
||||||
Result := RoundChecked(FScale.X * AX + FOffset.X);
|
Result := ImgRoundChecked(FScale.X * AX + FOffset.X);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TChart.XImageToGraph(AX: Integer): Double;
|
function TChart.XImageToGraph(AX: Integer): Double;
|
||||||
begin
|
begin
|
||||||
Result := (AX - FOffset.X) / FScale.X;
|
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;
|
end;
|
||||||
|
|
||||||
function TChart.YGraphToImage(AY: Double): Integer;
|
function TChart.YGraphToImage(AY: Double): Integer;
|
||||||
begin
|
begin
|
||||||
Result := RoundChecked(FScale.Y * AY + FOffset.Y);
|
Result := ImgRoundChecked(FScale.Y * AY + FOffset.Y);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TChart.YImageToGraph(AY: Integer): Double;
|
function TChart.YImageToGraph(AY: Integer): Double;
|
||||||
begin
|
begin
|
||||||
Result := (AY - FOffset.Y) / FScale.Y;
|
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;
|
end;
|
||||||
|
|
||||||
procedure TChart.ZoomFull(AImmediateRecalc: Boolean);
|
procedure TChart.ZoomFull(AImmediateRecalc: Boolean);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user