mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 20:39:09 +02:00
TAChart: add TChartMarks.Distance property.
git-svn-id: trunk@18883 -
This commit is contained in:
parent
6e5def3ad7
commit
ddda8edc89
@ -1181,7 +1181,7 @@ var
|
|||||||
h: Integer;
|
h: Integer;
|
||||||
begin
|
begin
|
||||||
if not Marks.IsMarkLabelsVisible then exit;
|
if not Marks.IsMarkLabelsVisible then exit;
|
||||||
h := ACanvas.TextHeight('0') + 10 + 2 * 2 + 4;
|
h := ACanvas.TextHeight('0') + Marks.Distance + 2 * 2 + 4;
|
||||||
AMargins.Top := Max(AMargins.Top, h);
|
AMargins.Top := Max(AMargins.Top, h);
|
||||||
AMargins.Bottom := Max(AMargins.Bottom, h);
|
AMargins.Bottom := Max(AMargins.Bottom, h);
|
||||||
end;
|
end;
|
||||||
@ -1215,8 +1215,6 @@ var
|
|||||||
prevLabelRect: TRect = (Left: 0; Top: 0; Right: 0; Bottom: 0);
|
prevLabelRect: TRect = (Left: 0; Top: 0; Right: 0; Bottom: 0);
|
||||||
|
|
||||||
procedure DrawLabel;
|
procedure DrawLabel;
|
||||||
const
|
|
||||||
DIST = 10;
|
|
||||||
var
|
var
|
||||||
labelRect: TRect;
|
labelRect: TRect;
|
||||||
dummy: TRect = (Left: 0; Top: 0; Right: 0; Bottom: 0);
|
dummy: TRect = (Left: 0; Top: 0; Right: 0; Bottom: 0);
|
||||||
@ -1231,8 +1229,10 @@ var
|
|||||||
labelSize := ACanvas.TextExtent(labelText);
|
labelSize := ACanvas.TextExtent(labelText);
|
||||||
xc := (r.Left + r.Right) div 2;
|
xc := (r.Left + r.Right) div 2;
|
||||||
labelPos.X := xc - labelSize.cx div 2;
|
labelPos.X := xc - labelSize.cx div 2;
|
||||||
labelPos.Y :=
|
if barTopY = 0 then
|
||||||
ifthen(barTopY = 0, r.Bottom + DIST, r.Top - DIST - labelSize.cy);
|
labelPos.Y := r.Bottom + Marks.Distance
|
||||||
|
else
|
||||||
|
labelPos.Y := r.Top - Marks.Distance - labelSize.cy;
|
||||||
labelRect := Bounds(labelPos.X, labelPos.Y, labelSize.cx, labelSize.cy);
|
labelRect := Bounds(labelPos.X, labelPos.Y, labelSize.cx, labelSize.cy);
|
||||||
InflateRect(labelRect, 4, 2);
|
InflateRect(labelRect, 4, 2);
|
||||||
if
|
if
|
||||||
@ -1389,7 +1389,6 @@ var
|
|||||||
a, b, center: TPoint;
|
a, b, center: TPoint;
|
||||||
const
|
const
|
||||||
MARGIN = 8;
|
MARGIN = 8;
|
||||||
MARKS_DIST = 32;
|
|
||||||
MarkYMargin = 2;
|
MarkYMargin = 2;
|
||||||
MarkXMargin = 4;
|
MarkXMargin = 4;
|
||||||
begin
|
begin
|
||||||
@ -1415,7 +1414,7 @@ begin
|
|||||||
YImageMin - center.y - MaxIntValue(labelHeights));
|
YImageMin - center.y - MaxIntValue(labelHeights));
|
||||||
end;
|
end;
|
||||||
if Marks.IsMarkLabelsVisible then
|
if Marks.IsMarkLabelsVisible then
|
||||||
radius -= MARKS_DIST;
|
radius -= Marks.Distance;
|
||||||
radius := Max(radius - MARGIN, 0);
|
radius := Max(radius - MARGIN, 0);
|
||||||
|
|
||||||
prevAngle := 0;
|
prevAngle := 0;
|
||||||
@ -1436,7 +1435,7 @@ begin
|
|||||||
if not Marks.IsMarkLabelsVisible then continue;
|
if not Marks.IsMarkLabelsVisible then continue;
|
||||||
|
|
||||||
a := LineEndPoint(center, prevAngle - angleStep / 2, radius);
|
a := LineEndPoint(center, prevAngle - angleStep / 2, radius);
|
||||||
b := LineEndPoint(center, prevAngle - angleStep / 2, radius + MARKS_DIST);
|
b := LineEndPoint(center, prevAngle - angleStep / 2, radius + Marks.Distance);
|
||||||
|
|
||||||
// line from mark to pie
|
// line from mark to pie
|
||||||
ACanvas.Pen.Color := LabelToPieLinkColor;
|
ACanvas.Pen.Color := LabelToPieLinkColor;
|
||||||
@ -1454,7 +1453,6 @@ begin
|
|||||||
b.x - MarkXMargin, b.y - MarkYMargin,
|
b.x - MarkXMargin, b.y - MarkYMargin,
|
||||||
b.x + labelWidths[i] + MarkXMargin, b.y + labelHeights[i] + MarkYMargin);
|
b.x + labelWidths[i] + MarkXMargin, b.y + labelHeights[i] + MarkYMargin);
|
||||||
ACanvas.TextOut(b.x, b.y, labelTexts[i]);
|
ACanvas.TextOut(b.x, b.y, labelTexts[i]);
|
||||||
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -158,8 +158,11 @@ type
|
|||||||
|
|
||||||
TChartMarks = class(TChartElement)
|
TChartMarks = class(TChartElement)
|
||||||
private
|
private
|
||||||
|
FDistance: Integer;
|
||||||
FFormat: String;
|
FFormat: String;
|
||||||
FStyle: TSeriesMarksStyle;
|
FStyle: TSeriesMarksStyle;
|
||||||
|
|
||||||
|
procedure SetDistance(const AValue: Integer);
|
||||||
procedure SetFormat(const AValue: String);
|
procedure SetFormat(const AValue: String);
|
||||||
procedure SetStyle(const AValue: TSeriesMarksStyle);
|
procedure SetStyle(const AValue: TSeriesMarksStyle);
|
||||||
public
|
public
|
||||||
@ -168,6 +171,8 @@ type
|
|||||||
procedure Assign(Source: TPersistent); override;
|
procedure Assign(Source: TPersistent); override;
|
||||||
function IsMarkLabelsVisible: Boolean;
|
function IsMarkLabelsVisible: Boolean;
|
||||||
published
|
published
|
||||||
|
// Distance between series point and label.
|
||||||
|
property Distance: Integer read FDistance write SetDistance default 20;
|
||||||
property Format: String read FFormat write SetFormat;
|
property Format: String read FFormat write SetFormat;
|
||||||
property Style: TSeriesMarksStyle
|
property Style: TSeriesMarksStyle
|
||||||
read FStyle write SetStyle default smsNone;
|
read FStyle write SetStyle default smsNone;
|
||||||
@ -446,6 +451,7 @@ begin
|
|||||||
inherited Assign(Source);
|
inherited Assign(Source);
|
||||||
if Source is TChartMarks then
|
if Source is TChartMarks then
|
||||||
with TChartMarks(Source) do begin
|
with TChartMarks(Source) do begin
|
||||||
|
Self.FDistance := FDistance;
|
||||||
Self.FFormat := FFormat;
|
Self.FFormat := FFormat;
|
||||||
Self.FStyle := FStyle;
|
Self.FStyle := FStyle;
|
||||||
end;
|
end;
|
||||||
@ -454,6 +460,7 @@ end;
|
|||||||
constructor TChartMarks.Create(AOwner: TCustomChart);
|
constructor TChartMarks.Create(AOwner: TCustomChart);
|
||||||
begin
|
begin
|
||||||
inherited Create(AOwner);
|
inherited Create(AOwner);
|
||||||
|
FDistance := 20;
|
||||||
FStyle := smsNone;
|
FStyle := smsNone;
|
||||||
FVisible := true;
|
FVisible := true;
|
||||||
end;
|
end;
|
||||||
@ -463,6 +470,13 @@ begin
|
|||||||
Result := Visible and (Style <> smsNone) and (Format <> '');
|
Result := Visible and (Style <> smsNone) and (Format <> '');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TChartMarks.SetDistance(const AValue: Integer);
|
||||||
|
begin
|
||||||
|
if FDistance = AValue then exit;
|
||||||
|
FDistance := AValue;
|
||||||
|
StyleChanged(Self);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TChartMarks.SetFormat(const AValue: String);
|
procedure TChartMarks.SetFormat(const AValue: String);
|
||||||
begin
|
begin
|
||||||
if FFormat = AValue then exit;
|
if FFormat = AValue then exit;
|
||||||
|
Loading…
Reference in New Issue
Block a user