mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 17:19:19 +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));
|
((ldTop, ldBottom), (ldRight, ldLeft));
|
||||||
var
|
var
|
||||||
isNeg: Boolean;
|
isNeg: Boolean;
|
||||||
ref: Double;
|
|
||||||
begin
|
begin
|
||||||
with Extent do
|
|
||||||
ref := (a.Y + b.Y) * 0.5;
|
|
||||||
case MarkPositions of
|
case MarkPositions of
|
||||||
lmpOutside: isNeg := Source[AIndex]^.Y < ref;
|
lmpOutside: isNeg := Source[AIndex]^.Y < GetZeroLevel;
|
||||||
lmpPositive: isNeg := false;
|
lmpPositive: isNeg := false;
|
||||||
lmpNegative: isNeg := true;
|
lmpNegative: isNeg := true;
|
||||||
lmpInside: isNeg := Source[AIndex]^.Y >= ref;
|
lmpInside: isNeg := Source[AIndex]^.Y >= GetZeroLevel;
|
||||||
lmpInsideCenter: isNeg := false;
|
lmpInsideCenter: isNeg := Source[AIndex]^.Y < GetZeroLevel;
|
||||||
end;
|
end;
|
||||||
Result := DIR[IsRotated, isNeg];
|
Result := DIR[IsRotated, isNeg];
|
||||||
end;
|
end;
|
||||||
@ -1732,65 +1729,50 @@ end;
|
|||||||
procedure TBasicPointSeries.UpdateMargins(
|
procedure TBasicPointSeries.UpdateMargins(
|
||||||
ADrawer: IChartDrawer; var AMargins: TRect);
|
ADrawer: IChartDrawer; var AMargins: TRect);
|
||||||
var
|
var
|
||||||
i, distX, distY: Integer;
|
i, dist: Integer;
|
||||||
labelText: String;
|
labelText: String;
|
||||||
dir: TLabelDirection;
|
dir: TLabelDirection;
|
||||||
gp: TDoublePoint;
|
m: array [TLabelDirection] of Integer absolute AMargins;
|
||||||
p: TPoint;
|
|
||||||
zero: Double;
|
zero: Double;
|
||||||
r, rExtent: TRect;
|
gp: TDoublePoint;
|
||||||
|
valueIsPositive: Boolean;
|
||||||
begin
|
begin
|
||||||
if not Marks.IsMarkLabelsVisible or not Marks.AutoMargins then exit;
|
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;
|
zero := GetZeroLevel;
|
||||||
|
|
||||||
for i := 0 to Count - 1 do begin
|
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);
|
gp := GetGraphPoint(i);
|
||||||
p := FChart.GraphToImage(gp);
|
if not ParentChart.IsPointInViewPort(gp) then continue;
|
||||||
UpdateMinMax(p.X, rExtent.Left, rExtent.Right);
|
labelText := FormattedMark(i);
|
||||||
UpdateMinMax(p.Y, rExtent.Top, rExtent.Bottom);
|
if labelText = '' then continue;
|
||||||
|
|
||||||
if MarkPositions = lmpInsideCenter then
|
valueIsPositive := TDoublePointBoolArr(gp)[not IsRotated] > zero;
|
||||||
p.y := (p.y + FChart.YGraphToImage(zero)) div 2;
|
dir := GetLabelDirection(i);
|
||||||
|
|
||||||
case dir of
|
with Marks.MeasureLabel(ADrawer, labelText) do
|
||||||
ldLeft : UpdateMinMax(p.X - distX, r.Left, r.Right);
|
dist := IfThen(dir in [ldLeft, ldRight], cx, cy);
|
||||||
ldRight : UpdateMinMax(p.X + distX, r.Left, r.Right);
|
if Marks.DistanceToCenter then
|
||||||
ldTop : UpdateMinMax(p.Y - distY, r.Top, r.Bottom);
|
dist := dist div 2;
|
||||||
ldBottom : UpdateMinMax(p.Y + distY, r.Top, r.Bottom);
|
|
||||||
end;
|
if valueIsPositive then begin
|
||||||
if IsRotated then begin
|
if Marks.DistanceToCenter then
|
||||||
UpdateMinMax(p.Y - distY, r.Top, r.Bottom);
|
case dir of
|
||||||
UpdateMinMax(p.Y + distY, r.Top, r.Bottom);
|
ldBottom: dir := ldTop;
|
||||||
|
ldLeft: dir := ldRight;
|
||||||
|
end;
|
||||||
|
if dir in [ldTop, ldRight] then
|
||||||
|
m[dir] := Max(m[dir], dist + Marks.Distance);
|
||||||
end else begin
|
end else begin
|
||||||
UpdateMinMax(p.X - distX, r.Left, r.Right);
|
if Marks.DistanceToCenter then
|
||||||
UpdateMinMax(p.X + distX, r.Left, r.Right);
|
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;
|
||||||
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;
|
end;
|
||||||
|
|
||||||
procedure TBasicPointSeries.UpdateMinXRange;
|
procedure TBasicPointSeries.UpdateMinXRange;
|
||||||
|
Loading…
Reference in New Issue
Block a user