TAChart: Implement left/right mark positions for pie series

git-svn-id: trunk@30573 -
This commit is contained in:
ask 2011-05-06 09:59:40 +00:00
parent bfb3e89980
commit 22f53e500e

View File

@ -38,7 +38,7 @@ type
FLabel: TLabelParams; FLabel: TLabelParams;
end; end;
TPieMarkPositions = (pmpAround, pmpInside); TPieMarkPositions = (pmpAround, pmpInside, pmpLeftRight);
{ TCustomPieSeries } { TCustomPieSeries }
@ -333,7 +333,12 @@ function TCustomPieSeries.TryRadius(ADrawer: IChartDrawer): TRect;
var var
i: Integer; i: Integer;
p: TPointArray; p: TPointArray;
d: TPoint;
function Ofs(AAngle: Double): TPoint;
begin
Result := EndPoint(AAngle, Marks.Distance + LabelExtraDist(p, AAngle));
end;
begin begin
with ALabel do begin with ALabel do begin
FCenter := FAttachment; FCenter := FAttachment;
@ -343,10 +348,13 @@ 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));
d := EndPoint(AAngle, Marks.Distance + LabelExtraDist(p, AAngle));
case MarkPositions of case MarkPositions of
pmpAround: FCenter += d; pmpAround:
pmpInside: FCenter -= d; FCenter += Ofs(AAngle);
pmpInside:
FCenter -= Ofs(AAngle);
pmpLeftRight:
FCenter += Ofs(IfThen(InRange(AAngle, Pi / 2, 3 * Pi / 2), Pi, 0));
end; 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);