mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 09:59:20 +02:00
TAChart: Initial version of 3-d pie charts
git-svn-id: trunk@35624 -
This commit is contained in:
parent
1bb99f869b
commit
31c109090a
@ -194,10 +194,15 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomPieSeries.Draw(ADrawer: IChartDrawer);
|
procedure TCustomPieSeries.Draw(ADrawer: IChartDrawer);
|
||||||
|
const
|
||||||
|
STEP = 4;
|
||||||
var
|
var
|
||||||
prevAngle: Double = 0;
|
prevAngle: Double = 0;
|
||||||
prevLabelPoly: TPointArray = nil;
|
prevLabelPoly: TPointArray = nil;
|
||||||
ps: TPieSlice;
|
ps: TPieSlice;
|
||||||
|
i, numSteps: Integer;
|
||||||
|
nextAngle: Double;
|
||||||
|
p: array of TPoint;
|
||||||
begin
|
begin
|
||||||
if IsEmpty then exit;
|
if IsEmpty then exit;
|
||||||
|
|
||||||
@ -205,6 +210,38 @@ begin
|
|||||||
Measure(ADrawer);
|
Measure(ADrawer);
|
||||||
|
|
||||||
ADrawer.PrepareSimplePen(clBlack);
|
ADrawer.PrepareSimplePen(clBlack);
|
||||||
|
if Depth > 0 then begin
|
||||||
|
prevAngle := 0;
|
||||||
|
for ps in FSlices do begin
|
||||||
|
nextAngle := prevAngle + ps.FAngle;
|
||||||
|
if ps.FVisible then begin
|
||||||
|
ADrawer.SetBrushParams(bsSolid, SliceColor(ps.FOrigIndex));
|
||||||
|
if not InRange(nextAngle, Pi / 4, 5 * Pi / 4) then
|
||||||
|
ADrawer.DrawLineDepth(
|
||||||
|
ps.FBase, ps.FBase + RotatePointX(FRadius, -nextAngle), Depth);
|
||||||
|
if InRange(prevAngle, Pi / 4, 5 * Pi / 4) then
|
||||||
|
ADrawer.DrawLineDepth(
|
||||||
|
ps.FBase, ps.FBase + RotatePointX(FRadius, -prevAngle), Depth);
|
||||||
|
end;
|
||||||
|
prevAngle := nextAngle;
|
||||||
|
end;
|
||||||
|
prevAngle := 0;
|
||||||
|
for ps in FSlices do begin
|
||||||
|
nextAngle := prevAngle + ps.FAngle;
|
||||||
|
if ps.FVisible then begin
|
||||||
|
ADrawer.SetBrushParams(bsSolid, SliceColor(ps.FOrigIndex));
|
||||||
|
numSteps := Round(2 * Pi * ps.FAngle * FRadius / STEP);
|
||||||
|
SetLength(p, 2 * numSteps);
|
||||||
|
for i := 0 to numSteps - 1 do begin
|
||||||
|
p[i] := ps.FBase + RotatePointX(FRadius, -prevAngle - ps.FAngle * i / (numSteps - 1));
|
||||||
|
p[High(p) - i] := p[i] + Point(Depth, -Depth);
|
||||||
|
end;
|
||||||
|
ADrawer.Polygon(p, 0, Length(p));
|
||||||
|
end;
|
||||||
|
prevAngle := nextAngle;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
prevAngle := 0;
|
||||||
for ps in FSlices do begin
|
for ps in FSlices do begin
|
||||||
if ps.FVisible then begin
|
if ps.FVisible then begin
|
||||||
ADrawer.SetBrushParams(bsSolid, SliceColor(ps.FOrigIndex));
|
ADrawer.SetBrushParams(bsSolid, SliceColor(ps.FOrigIndex));
|
||||||
@ -435,7 +472,11 @@ begin
|
|||||||
a := prevAngle + FAngle / 2;
|
a := prevAngle + FAngle / 2;
|
||||||
if Exploded and (di^.X > 0) then
|
if Exploded and (di^.X > 0) then
|
||||||
FBase += EndPoint(a, FRadius * di^.X);
|
FBase += EndPoint(a, FRadius * di^.X);
|
||||||
ExpandRect(Result, FBase, FRadius, - prevAngle, - prevAngle - FAngle);
|
ExpandRect(Result, FBase, FRadius, -prevAngle, -prevAngle - FAngle);
|
||||||
|
if Depth > 0 then
|
||||||
|
ExpandRect(
|
||||||
|
Result, FBase + Point(Depth, -Depth),
|
||||||
|
FRadius, -prevAngle, -prevAngle - FAngle);
|
||||||
FLabel.FAttachment := EndPoint(a, FRadius) + FBase;
|
FLabel.FAttachment := EndPoint(a, FRadius) + FBase;
|
||||||
PrepareLabel(FLabel, i, a);
|
PrepareLabel(FLabel, i, a);
|
||||||
end;
|
end;
|
||||||
|
@ -111,6 +111,7 @@ type
|
|||||||
|
|
||||||
TPieSeries = class(TCustomPieSeries)
|
TPieSeries = class(TCustomPieSeries)
|
||||||
published
|
published
|
||||||
|
property Depth;
|
||||||
property Exploded;
|
property Exploded;
|
||||||
property FixedRadius;
|
property FixedRadius;
|
||||||
property MarkPositions;
|
property MarkPositions;
|
||||||
|
Loading…
Reference in New Issue
Block a user