mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 12:09:26 +02:00
TAChart: Add PieSeries.MarkPositions property. Implement labels inside of slices.
git-svn-id: trunk@30570 -
This commit is contained in:
parent
36f8395af2
commit
bad4e3f9a3
@ -38,9 +38,16 @@ type
|
|||||||
FLabel: TLabelParams;
|
FLabel: TLabelParams;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
TPieMarkPositions = (pmpAround, pmpInside);
|
||||||
|
|
||||||
{ TCustomPieSeries }
|
{ TCustomPieSeries }
|
||||||
|
|
||||||
TCustomPieSeries = class(TChartSeries)
|
TCustomPieSeries = class(TChartSeries)
|
||||||
|
private
|
||||||
|
FCenter: TPoint;
|
||||||
|
FMarkPositions: TPieMarkPositions;
|
||||||
|
FRadius: Integer;
|
||||||
|
FSlices: array of TPieSlice;
|
||||||
private
|
private
|
||||||
FExploded: Boolean;
|
FExploded: Boolean;
|
||||||
FFixedRadius: TChartDistance;
|
FFixedRadius: TChartDistance;
|
||||||
@ -48,13 +55,10 @@ type
|
|||||||
procedure Measure(ADrawer: IChartDrawer);
|
procedure Measure(ADrawer: IChartDrawer);
|
||||||
procedure SetExploded(AValue: Boolean);
|
procedure SetExploded(AValue: Boolean);
|
||||||
procedure SetFixedRadius(AValue: TChartDistance);
|
procedure SetFixedRadius(AValue: TChartDistance);
|
||||||
|
procedure SetMarkPositions(AValue: TPieMarkPositions);
|
||||||
procedure SetRotateLabels(AValue: Boolean);
|
procedure SetRotateLabels(AValue: Boolean);
|
||||||
function SliceColor(AIndex: Integer): TColor;
|
function SliceColor(AIndex: Integer): TColor;
|
||||||
function TryRadius(ADrawer: IChartDrawer): TRect;
|
function TryRadius(ADrawer: IChartDrawer): TRect;
|
||||||
private
|
|
||||||
FCenter: TPoint;
|
|
||||||
FRadius: Integer;
|
|
||||||
FSlices: array of TPieSlice;
|
|
||||||
protected
|
protected
|
||||||
procedure AfterAdd; override;
|
procedure AfterAdd; override;
|
||||||
procedure GetLegendItems(AItems: TChartLegendItems); override;
|
procedure GetLegendItems(AItems: TChartLegendItems); override;
|
||||||
@ -68,6 +72,8 @@ type
|
|||||||
property Exploded: Boolean read FExploded write SetExploded default false;
|
property Exploded: Boolean read FExploded write SetExploded default false;
|
||||||
property FixedRadius: TChartDistance
|
property FixedRadius: TChartDistance
|
||||||
read FFixedRadius write SetFixedRadius default 0;
|
read FFixedRadius write SetFixedRadius default 0;
|
||||||
|
property MarkPositions: TPieMarkPositions
|
||||||
|
read FMarkPositions write SetMarkPositions default pmpAround;
|
||||||
property RotateLabels: Boolean
|
property RotateLabels: Boolean
|
||||||
read FRotateLabels write SetRotateLabels default false;
|
read FRotateLabels write SetRotateLabels default false;
|
||||||
end;
|
end;
|
||||||
@ -261,6 +267,13 @@ begin
|
|||||||
UpdateParentChart;
|
UpdateParentChart;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCustomPieSeries.SetMarkPositions(AValue: TPieMarkPositions);
|
||||||
|
begin
|
||||||
|
if FMarkPositions = AValue then exit;
|
||||||
|
FMarkPositions := AValue;
|
||||||
|
UpdateParentChart;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCustomPieSeries.SetRotateLabels(AValue: Boolean);
|
procedure TCustomPieSeries.SetRotateLabels(AValue: Boolean);
|
||||||
begin
|
begin
|
||||||
if FRotateLabels = AValue then exit;
|
if FRotateLabels = AValue then exit;
|
||||||
@ -320,6 +333,7 @@ function TCustomPieSeries.TryRadius(ADrawer: IChartDrawer): TRect;
|
|||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
p: TPointArray;
|
p: TPointArray;
|
||||||
|
d: TPoint;
|
||||||
begin
|
begin
|
||||||
with ALabel do begin
|
with ALabel do begin
|
||||||
FCenter := FAttachment;
|
FCenter := FAttachment;
|
||||||
@ -329,7 +343,11 @@ function TCustomPieSeries.TryRadius(ADrawer: IChartDrawer): TRect;
|
|||||||
if RotateLabels then
|
if RotateLabels then
|
||||||
Marks.SetAdditionalAngle(AAngle);
|
Marks.SetAdditionalAngle(AAngle);
|
||||||
p := Marks.GetLabelPolygon(ADrawer, ADrawer.TextExtent(FText));
|
p := Marks.GetLabelPolygon(ADrawer, ADrawer.TextExtent(FText));
|
||||||
FCenter += EndPoint(AAngle, Marks.Distance + LabelExtraDist(p, AAngle));
|
d := EndPoint(AAngle, Marks.Distance + LabelExtraDist(p, AAngle));
|
||||||
|
case MarkPositions of
|
||||||
|
pmpAround: FCenter += d;
|
||||||
|
pmpInside: FCenter -= d;
|
||||||
|
end;
|
||||||
for i := 0 to High(p) do
|
for i := 0 to High(p) do
|
||||||
ExpandRect(Result, p[i] + FCenter);
|
ExpandRect(Result, p[i] + FCenter);
|
||||||
end;
|
end;
|
||||||
|
@ -111,6 +111,7 @@ type
|
|||||||
published
|
published
|
||||||
property Exploded;
|
property Exploded;
|
||||||
property FixedRadius;
|
property FixedRadius;
|
||||||
|
property MarkPositions;
|
||||||
property RotateLabels;
|
property RotateLabels;
|
||||||
property Source;
|
property Source;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user