mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-22 16:19:36 +02:00
TAChart: Undo r60055 #1a8ce7d395
git-svn-id: branches/fixes_2_0@60067 -
This commit is contained in:
parent
1a8ce7d395
commit
6bdeee7347
@ -1393,16 +1393,13 @@ const
|
||||
((ldTop, ldBottom), (ldRight, ldLeft));
|
||||
var
|
||||
isNeg: Boolean;
|
||||
ref: Double;
|
||||
begin
|
||||
with Extent do
|
||||
ref := (a.Y + b.Y) * 0.5;
|
||||
case MarkPositions of
|
||||
lmpOutside: isNeg := Source[AIndex]^.Y < ref;
|
||||
lmpOutside: isNeg := Source[AIndex]^.Y < GetZeroLevel;
|
||||
lmpPositive: isNeg := false;
|
||||
lmpNegative: isNeg := true;
|
||||
lmpInside: isNeg := Source[AIndex]^.Y >= ref;
|
||||
lmpInsideCenter: isNeg := false;
|
||||
lmpInside: isNeg := Source[AIndex]^.Y >= GetZeroLevel;
|
||||
lmpInsideCenter: isNeg := Source[AIndex]^.Y < GetZeroLevel;
|
||||
end;
|
||||
Result := DIR[IsRotated, isNeg];
|
||||
end;
|
||||
@ -1732,65 +1729,50 @@ end;
|
||||
procedure TBasicPointSeries.UpdateMargins(
|
||||
ADrawer: IChartDrawer; var AMargins: TRect);
|
||||
var
|
||||
i, distX, distY: Integer;
|
||||
i, dist: Integer;
|
||||
labelText: String;
|
||||
dir: TLabelDirection;
|
||||
gp: TDoublePoint;
|
||||
p: TPoint;
|
||||
m: array [TLabelDirection] of Integer absolute AMargins;
|
||||
zero: Double;
|
||||
r, rExtent: TRect;
|
||||
gp: TDoublePoint;
|
||||
valueIsPositive: Boolean;
|
||||
begin
|
||||
if not Marks.IsMarkLabelsVisible or not Marks.AutoMargins then exit;
|
||||
if MarkPositions = lmpInsideCenter then exit;
|
||||
|
||||
r := Rect(MaxInt, MaxInt, -MaxInt, -MaxInt);
|
||||
with FChart.LogicalExtent do begin
|
||||
rExtent.TopLeft := FChart.GraphToImage(DoublePoint(a.x, b.y));
|
||||
rExtent.BottomRight := FChart.GraphToImage(DoublePoint(b.x, a.y));
|
||||
end;
|
||||
zero := GetZeroLevel;
|
||||
|
||||
for i := 0 to Count - 1 do begin
|
||||
labelText := FormattedMark(i);
|
||||
if labelText = '' then Continue;
|
||||
|
||||
dir := GetLabelDirection(i);
|
||||
with Marks.MeasureLabel(ADrawer, labelText) do begin
|
||||
distY := IfThen(IsRotated, cx, cy);
|
||||
distX := IfThen(IsRotated, cy, cx) div 2;
|
||||
end;
|
||||
if Marks.DistanceToCenter then
|
||||
distY := distY div 2;
|
||||
distY := distY + Marks.Distance;
|
||||
if IsRotated then
|
||||
Exchange(distX, distY);
|
||||
|
||||
gp := GetGraphPoint(i);
|
||||
p := FChart.GraphToImage(gp);
|
||||
UpdateMinMax(p.X, rExtent.Left, rExtent.Right);
|
||||
UpdateMinMax(p.Y, rExtent.Top, rExtent.Bottom);
|
||||
if not ParentChart.IsPointInViewPort(gp) then continue;
|
||||
labelText := FormattedMark(i);
|
||||
if labelText = '' then continue;
|
||||
|
||||
if MarkPositions = lmpInsideCenter then
|
||||
p.y := (p.y + FChart.YGraphToImage(zero)) div 2;
|
||||
valueIsPositive := TDoublePointBoolArr(gp)[not IsRotated] > zero;
|
||||
dir := GetLabelDirection(i);
|
||||
|
||||
case dir of
|
||||
ldLeft : UpdateMinMax(p.X - distX, r.Left, r.Right);
|
||||
ldRight : UpdateMinMax(p.X + distX, r.Left, r.Right);
|
||||
ldTop : UpdateMinMax(p.Y - distY, r.Top, r.Bottom);
|
||||
ldBottom : UpdateMinMax(p.Y + distY, r.Top, r.Bottom);
|
||||
end;
|
||||
if IsRotated then begin
|
||||
UpdateMinMax(p.Y - distY, r.Top, r.Bottom);
|
||||
UpdateMinMax(p.Y + distY, r.Top, r.Bottom);
|
||||
with Marks.MeasureLabel(ADrawer, labelText) do
|
||||
dist := IfThen(dir in [ldLeft, ldRight], cx, cy);
|
||||
if Marks.DistanceToCenter then
|
||||
dist := dist div 2;
|
||||
|
||||
if valueIsPositive then begin
|
||||
if Marks.DistanceToCenter then
|
||||
case dir of
|
||||
ldBottom: dir := ldTop;
|
||||
ldLeft: dir := ldRight;
|
||||
end;
|
||||
if dir in [ldTop, ldRight] then
|
||||
m[dir] := Max(m[dir], dist + Marks.Distance);
|
||||
end else begin
|
||||
UpdateMinMax(p.X - distX, r.Left, r.Right);
|
||||
UpdateMinMax(p.X + distX, r.Left, r.Right);
|
||||
if Marks.DistanceToCenter then
|
||||
case dir of
|
||||
ldTop: dir := ldBottom;
|
||||
ldRight: dir := ldLeft;
|
||||
end;
|
||||
if dir in [ldBottom, ldLeft] then
|
||||
m[dir] := Max(m[dir], dist + Marks.Distance);
|
||||
end;
|
||||
end;
|
||||
|
||||
AMargins.Top := Max(AMargins.Top, -(r.Top - rExtent.Top));
|
||||
AMargins.Bottom := Max(AMargins.Bottom, (r.Bottom - rExtent.Bottom));
|
||||
AMargins.Left := Max(AMargins.Left, -(r.Left - rExtent.Left));
|
||||
AMargins.Right := Max(AMargins.Right, (r.Right - rExtent.Right));
|
||||
end;
|
||||
|
||||
procedure TBasicPointSeries.UpdateMinXRange;
|
||||
|
Loading…
Reference in New Issue
Block a user