TAChart: New property MarkPositionCentered for TPieSeries.

git-svn-id: trunk@60688 -
This commit is contained in:
wp 2019-03-15 19:04:46 +00:00
parent bcabe6b804
commit 2a24bff643
5 changed files with 226 additions and 60 deletions

View File

@ -1,17 +1,17 @@
object Form1: TForm1 object Form1: TForm1
Left = 459 Left = 443
Height = 482 Height = 559
Top = 346 Top = 340
Width = 580 Width = 580
Caption = 'Form1' Caption = 'Form1'
ClientHeight = 482 ClientHeight = 559
ClientWidth = 580 ClientWidth = 580
OnCreate = FormCreate OnCreate = FormCreate
Position = poScreenCenter Position = poScreenCenter
LCLVersion = '2.1.0.0' LCLVersion = '2.1.0.0'
object PageControl1: TPageControl object PageControl1: TPageControl
Left = 0 Left = 0
Height = 482 Height = 559
Top = 0 Top = 0
Width = 580 Width = 580
ActivePage = tsPie ActivePage = tsPie
@ -20,12 +20,12 @@ object Form1: TForm1
TabOrder = 0 TabOrder = 0
object tsPie: TTabSheet object tsPie: TTabSheet
Caption = 'Pie' Caption = 'Pie'
ClientHeight = 454 ClientHeight = 531
ClientWidth = 572 ClientWidth = 572
object ChartPie: TChart object ChartPie: TChart
Left = 0 Left = 0
Height = 336 Height = 384
Top = 118 Top = 147
Width = 572 Width = 572
AxisList = < AxisList = <
item item
@ -65,26 +65,27 @@ object Form1: TForm1
object Panel1: TPanel object Panel1: TPanel
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
Left = 0 Left = 0
Height = 118 Height = 147
Top = 0 Top = 0
Width = 572 Width = 572
Align = alTop Align = alTop
Alignment = taLeftJustify Alignment = taLeftJustify
Anchors = [akTop, akRight]
AutoSize = True AutoSize = True
Caption = ' Click on a slice to explode/unexplode it' Caption = ' Click on a slice to explode/unexplode it'
ClientHeight = 118 ClientHeight = 147
ClientWidth = 572 ClientWidth = 572
TabOrder = 1 TabOrder = 1
object seWords: TSpinEdit object seWords: TSpinEdit
AnchorSideTop.Control = Panel1 AnchorSideTop.Control = Panel1
AnchorSideRight.Control = lblInnerRadius AnchorSideRight.Control = lblInnerRadius
Left = 326 Left = 324
Height = 23 Height = 23
Top = 7 Top = 7
Width = 72 Width = 72
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
BorderSpacing.Top = 6 BorderSpacing.Top = 6
BorderSpacing.Right = 16 BorderSpacing.Right = 24
MaxValue = 10 MaxValue = 10
OnChange = seWordsChange OnChange = seWordsChange
TabOrder = 0 TabOrder = 0
@ -94,7 +95,7 @@ object Form1: TForm1
AnchorSideTop.Control = seWords AnchorSideTop.Control = seWords
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = seWords AnchorSideRight.Control = seWords
Left = 255 Left = 253
Height = 15 Height = 15
Top = 11 Top = 11
Width = 63 Width = 63
@ -109,7 +110,7 @@ object Form1: TForm1
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = seWords AnchorSideRight.Control = seWords
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 326 Left = 324
Height = 23 Height = 23
Top = 34 Top = 34
Width = 72 Width = 72
@ -125,7 +126,7 @@ object Form1: TForm1
AnchorSideTop.Control = seLabelAngle AnchorSideTop.Control = seLabelAngle
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = seLabelAngle AnchorSideRight.Control = seLabelAngle
Left = 258 Left = 256
Height = 15 Height = 15
Top = 38 Top = 38
Width = 60 Width = 60
@ -135,31 +136,32 @@ object Form1: TForm1
ParentColor = False ParentColor = False
end end
object cbRotate: TCheckBox object cbRotate: TCheckBox
AnchorSideLeft.Control = cbMarkPositions AnchorSideTop.Control = cbMarkAttachment
AnchorSideTop.Control = cbMarkPositions
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = cbMarkAttachment
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 255 Left = 309
Height = 19 Height = 19
Top = 90 Top = 121
Width = 87 Width = 87
BorderSpacing.Bottom = 8 Alignment = taLeftJustify
Anchors = [akTop, akRight]
BorderSpacing.Top = 6
BorderSpacing.Bottom = 6
Caption = 'Rotate labels' Caption = 'Rotate labels'
OnChange = cbRotateChange OnChange = cbRotateChange
TabOrder = 2 TabOrder = 2
end end
object cbMarkPositions: TComboBox object cbMarkPositions: TComboBox
AnchorSideLeft.Control = lblWords AnchorSideTop.Control = cbMarkAttachment
AnchorSideTop.Control = lblLabelAngle AnchorSideRight.Control = seDepthBrightnessDelta
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = seLabelAngle
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 255 Left = 438
Height = 23 Height = 23
Top = 61 Top = 92
Width = 143 Width = 127
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akRight]
BorderSpacing.Top = 8 AutoSize = False
BorderSpacing.Bottom = 6 BorderSpacing.Bottom = 6
ItemHeight = 15 ItemHeight = 15
ItemIndex = 0 ItemIndex = 0
@ -177,7 +179,7 @@ object Form1: TForm1
AnchorSideLeft.Control = lblInnerRadius AnchorSideLeft.Control = lblInnerRadius
AnchorSideTop.Control = seLabelAngle AnchorSideTop.Control = seLabelAngle
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
Left = 414 Left = 420
Height = 19 Height = 19
Top = 36 Top = 36
Width = 34 Width = 34
@ -189,12 +191,12 @@ object Form1: TForm1
AnchorSideTop.Control = seWords AnchorSideTop.Control = seWords
AnchorSideRight.Control = Panel1 AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 497 Left = 503
Height = 23 Height = 23
Top = 7 Top = 7
Width = 62 Width = 62
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
BorderSpacing.Right = 12 BorderSpacing.Right = 6
OnChange = seInnerRadiusChange OnChange = seInnerRadiusChange
TabOrder = 5 TabOrder = 5
end end
@ -202,7 +204,7 @@ object Form1: TForm1
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = lblWords AnchorSideTop.Control = lblWords
AnchorSideRight.Control = seInnerRadius AnchorSideRight.Control = seInnerRadius
Left = 414 Left = 420
Height = 15 Height = 15
Top = 11 Top = 11
Width = 75 Width = 75
@ -217,7 +219,7 @@ object Form1: TForm1
AnchorSideTop.Control = Cb3D AnchorSideTop.Control = Cb3D
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = seDepth AnchorSideRight.Control = seDepth
Left = 457 Left = 463
Height = 15 Height = 15
Top = 38 Top = 38
Width = 32 Width = 32
@ -234,12 +236,12 @@ object Form1: TForm1
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = Panel1 AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 497 Left = 503
Height = 23 Height = 23
Top = 34 Top = 34
Width = 62 Width = 62
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
BorderSpacing.Right = 12 BorderSpacing.Right = 6
Enabled = False Enabled = False
OnChange = seDepthChange OnChange = seDepthChange
TabOrder = 6 TabOrder = 6
@ -251,13 +253,13 @@ object Form1: TForm1
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel1 AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 497 Left = 503
Height = 23 Height = 23
Top = 61 Top = 61
Width = 62 Width = 62
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
BorderSpacing.Top = 4 BorderSpacing.Top = 4
BorderSpacing.Right = 12 BorderSpacing.Right = 6
Enabled = False Enabled = False
MaxValue = 255 MaxValue = 255
MinValue = -255 MinValue = -255
@ -267,22 +269,104 @@ object Form1: TForm1
end end
object lblDepthBrightnessDelta: TLabel object lblDepthBrightnessDelta: TLabel
AnchorSideLeft.Control = cbMarkPositions AnchorSideLeft.Control = cbMarkPositions
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = seDepthBrightnessDelta AnchorSideTop.Control = seDepthBrightnessDelta
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = seDepthBrightnessDelta AnchorSideRight.Control = seDepthBrightnessDelta
Left = 398 Left = 411
Height = 15 Height = 15
Top = 65 Top = 65
Width = 91 Width = 84
Alignment = taRightJustify Alignment = taRightJustify
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akRight]
BorderSpacing.Right = 8 BorderSpacing.Right = 8
Caption = 'Brightness delta' Caption = 'Brightness delta'
Enabled = False Enabled = False
ParentColor = False ParentColor = False
WordWrap = True WordWrap = True
end end
object cbShowLabels: TCheckBox
AnchorSideTop.Control = seWords
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = lblWords
Left = 155
Height = 19
Top = 9
Width = 82
Anchors = [akTop, akRight]
BorderSpacing.Right = 16
Caption = 'Show labels'
Checked = True
OnChange = cbShowLabelsChange
State = cbChecked
TabOrder = 8
end
object lblDistance: TLabel
AnchorSideTop.Control = seDistance
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = seDistance
Left = 271
Height = 15
Top = 67
Width = 45
Anchors = [akTop, akRight]
BorderSpacing.Right = 8
Caption = 'Distance'
ParentColor = False
end
object seDistance: TSpinEdit
AnchorSideTop.Control = seLabelAngle
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = seLabelAngle
AnchorSideRight.Side = asrBottom
Left = 324
Height = 23
Top = 63
Width = 72
Anchors = [akTop, akRight]
BorderSpacing.Top = 6
OnChange = seDistanceChange
TabOrder = 9
Value = 40
end
object cbMarkAttachment: TComboBox
AnchorSideLeft.Control = lblDistance
AnchorSideTop.Control = seDistance
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = seDistance
AnchorSideRight.Side = asrBottom
Left = 271
Height = 23
Top = 92
Width = 125
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6
BorderSpacing.Bottom = 6
ItemHeight = 15
ItemIndex = 0
Items.Strings = (
'Default'
'Edge'
'Center'
)
OnChange = cbMarkAttachmentChange
Style = csDropDownList
TabOrder = 10
Text = 'Default'
end
object cbMarkPositionsCentered: TCheckBox
AnchorSideTop.Control = cbRotate
AnchorSideRight.Control = cbMarkPositions
AnchorSideRight.Side = asrBottom
Left = 418
Height = 19
Top = 121
Width = 147
Alignment = taLeftJustify
Anchors = [akTop, akRight]
Caption = 'Mark positions centered'
OnChange = cbMarkPositionsCenteredChange
TabOrder = 11
end
end end
end end
object tsPolar: TTabSheet object tsPolar: TTabSheet
@ -423,7 +507,7 @@ object Form1: TForm1
end end
object ListChartSource1: TListChartSource object ListChartSource1: TListChartSource
DataPoints.Strings = ( DataPoints.Strings = (
'0|5|?|' '0|7|?|'
'0|3|?|' '0|3|?|'
'0|1|?|' '0|1|?|'
'0.20000000000000001|0.20000000000000001|?|' '0.20000000000000001|0.20000000000000001|?|'

View File

@ -7,13 +7,14 @@ interface
uses uses
Classes, ComCtrls, ExtCtrls, Spin, StdCtrls, SysUtils, FileUtil, Forms, Classes, ComCtrls, ExtCtrls, Spin, StdCtrls, SysUtils, FileUtil, Forms,
Controls, Graphics, Dialogs, TAGraph, TARadialSeries, TASeries, TASources, Controls, Graphics, Dialogs, TAGraph, TARadialSeries, TASeries, TASources,
TATools; TATools, TACustomSeries;
type type
{ TForm1 } { TForm1 }
TForm1 = class(TForm) TForm1 = class(TForm)
cbMarkAttachment: TComboBox;
ChartPolar: TChart; ChartPolar: TChart;
ChartPolarSeries1: TPolarSeries; ChartPolarSeries1: TPolarSeries;
ChartPolarSeries2: TPolarSeries; ChartPolarSeries2: TPolarSeries;
@ -26,6 +27,9 @@ type
cbShowPoints: TCheckBox; cbShowPoints: TCheckBox;
cbFilled: TCheckBox; cbFilled: TCheckBox;
Cb3D: TCheckBox; Cb3D: TCheckBox;
cbShowLabels: TCheckBox;
cbMarkPositionsCentered: TCheckBox;
lblDistance: TLabel;
seDepth: TSpinEdit; seDepth: TSpinEdit;
seDepthBrightnessDelta: TSpinEdit; seDepthBrightnessDelta: TSpinEdit;
lblInnerRadius: TLabel; lblInnerRadius: TLabel;
@ -43,18 +47,23 @@ type
seWords: TSpinEdit; seWords: TSpinEdit;
seLabelAngle: TSpinEdit; seLabelAngle: TSpinEdit;
seInnerRadius: TSpinEdit; seInnerRadius: TSpinEdit;
seDistance: TSpinEdit;
tsPolar: TTabSheet; tsPolar: TTabSheet;
tsPie: TTabSheet; tsPie: TTabSheet;
procedure cbCloseCircleChange(Sender: TObject); procedure cbCloseCircleChange(Sender: TObject);
procedure cbFilledChange(Sender: TObject); procedure cbFilledChange(Sender: TObject);
procedure cbMarkAttachmentChange(Sender: TObject);
procedure cbMarkPositionsCenteredChange(Sender: TObject);
procedure cbMarkPositionsChange(Sender: TObject); procedure cbMarkPositionsChange(Sender: TObject);
procedure cbRotateChange(Sender: TObject); procedure cbRotateChange(Sender: TObject);
procedure cbShowLabelsChange(Sender: TObject);
procedure ChartPieMouseDown(Sender: TObject; Button: TMouseButton; procedure ChartPieMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer); Shift: TShiftState; X, Y: Integer);
procedure cbShowPointsChange(Sender: TObject); procedure cbShowPointsChange(Sender: TObject);
procedure Cb3DChange(Sender: TObject); procedure Cb3DChange(Sender: TObject);
procedure seDepthBrightnessDeltaChange(Sender: TObject); procedure seDepthBrightnessDeltaChange(Sender: TObject);
procedure seDepthChange(Sender: TObject); procedure seDepthChange(Sender: TObject);
procedure seDistanceChange(Sender: TObject);
procedure seInnerRadiusChange(Sender: TObject); procedure seInnerRadiusChange(Sender: TObject);
procedure FormCreate(Sender: TObject); procedure FormCreate(Sender: TObject);
procedure sbTransparencyChange(Sender: TObject); procedure sbTransparencyChange(Sender: TObject);
@ -70,7 +79,7 @@ implementation
{$R *.lfm} {$R *.lfm}
uses uses
TAChartUtils; TAChartUtils, TATextElements;
{ TForm1 } { TForm1 }
@ -86,6 +95,17 @@ begin
ChartPolarSeries2.Filled := cbFilled.Checked; ChartPolarSeries2.Filled := cbFilled.Checked;
end; end;
procedure TForm1.cbMarkAttachmentChange(Sender: TObject);
begin
ChartPiePieSeries1.Marks.Attachment :=
TChartMarkAttachment(cbMarkAttachment.ItemIndex);
end;
procedure TForm1.cbMarkPositionsCenteredChange(Sender: TObject);
begin
ChartPiePieSeries1.MarkPositionCentered := cbMarkPositionsCentered.Checked;
end;
procedure TForm1.cbMarkPositionsChange(Sender: TObject); procedure TForm1.cbMarkPositionsChange(Sender: TObject);
begin begin
ChartPiePieSeries1.MarkPositions := ChartPiePieSeries1.MarkPositions :=
@ -97,6 +117,22 @@ begin
ChartPiePieSeries1.RotateLabels := cbRotate.Checked; ChartPiePieSeries1.RotateLabels := cbRotate.Checked;
end; end;
procedure TForm1.cbShowLabelsChange(Sender: TObject);
begin
if cbShowLabels.Checked then
ChartPiePieSeries1.Marks.Style := smsLabel
else
ChartPiePieSeries1.Marks.Style := smsNone;
seWords.Enabled := cbShowLabels.Checked;
lblWords.Enabled := cbShowLabels.Checked;
seLabelAngle.Enabled := cbShowLabels.Checked;
lblLabelAngle.Enabled := cbShowLabels.Checked;
cbMarkPositions.Enabled := cbShowLabels.Checked;
cbMarkAttachment.Enabled := cbShowlabels.Checked;
cbMarkPositionsCentered.Enabled := cbShowLabels.Checked;
cbRotate.Enabled := cbShowLabels.Checked;
end;
procedure TForm1.cbShowPointsChange(Sender: TObject); procedure TForm1.cbShowPointsChange(Sender: TObject);
begin begin
ChartPolarSeries1.ShowPoints := cbShowPoints.Checked; ChartPolarSeries1.ShowPoints := cbShowPoints.Checked;
@ -125,6 +161,11 @@ begin
ChartPiePieSeries1.Depth := seDepth.Value; ChartPiePieSeries1.Depth := seDepth.Value;
end; end;
procedure TForm1.seDistanceChange(Sender: TObject);
begin
ChartPiePieSeries1.Marks.Distance := seDistance.Value;
end;
procedure TForm1.seInnerRadiusChange(Sender: TObject); procedure TForm1.seInnerRadiusChange(Sender: TObject);
begin begin
ChartPiePieSeries1.InnerRadiusPercent := seInnerRadius.Value; ChartPiePieSeries1.InnerRadiusPercent := seInnerRadius.Value;
@ -174,6 +215,12 @@ var
var var
i, j: Integer; i, j: Integer;
begin begin
if seWords.Value = 0 then begin
ChartPiePieSeries1.Marks.Style := smsValue;
exit;
end;
ChartPiePieSeries1.Marks.Style := smsLabel;
r := TMWCRandomGenerator.Create; r := TMWCRandomGenerator.Create;
try try
r.Seed := 9823743; r.Seed := 9823743;

View File

@ -65,13 +65,6 @@
<IncludeFiles Value="$(ProjOutDir)"/> <IncludeFiles Value="$(ProjOutDir)"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths> </SearchPaths>
<Linking>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
</CompilerOptions> </CompilerOptions>
<Debugging> <Debugging>
<Exceptions Count="3"> <Exceptions Count="3">

View File

@ -63,6 +63,7 @@ type
private private
FCenter: TPoint; FCenter: TPoint;
FMarkDistancePercent: Boolean; FMarkDistancePercent: Boolean;
FMarkPositionCentered: Boolean;
FMarkPositions: TPieMarkPositions; FMarkPositions: TPieMarkPositions;
FRadius: Integer; FRadius: Integer;
FInnerRadiusPercent: Integer; FInnerRadiusPercent: Integer;
@ -78,6 +79,7 @@ type
procedure SetFixedRadius(AValue: TChartDistance); procedure SetFixedRadius(AValue: TChartDistance);
procedure SetInnerRadiusPercent(AValue: Integer); procedure SetInnerRadiusPercent(AValue: Integer);
procedure SetMarkDistancePercent(AValue: Boolean); procedure SetMarkDistancePercent(AValue: Boolean);
procedure SetMarkPositionCentered(AValue: Boolean);
procedure SetMarkPositions(AValue: TPieMarkPositions); procedure SetMarkPositions(AValue: TPieMarkPositions);
procedure SetRotateLabels(AValue: Boolean); procedure SetRotateLabels(AValue: Boolean);
function SliceColor(AIndex: Integer): TColor; function SliceColor(AIndex: Integer): TColor;
@ -85,9 +87,11 @@ type
protected protected
function CalcInnerRadius: Integer; inline; function CalcInnerRadius: Integer; inline;
procedure GetLegendItems(AItems: TChartLegendItems); override; procedure GetLegendItems(AItems: TChartLegendItems); override;
property Radius: Integer read FRadius;
property InnerRadiusPercent: Integer property InnerRadiusPercent: Integer
read FInnerRadiusPercent write SetInnerRadiusPercent default 0; read FInnerRadiusPercent write SetInnerRadiusPercent default 0;
property MarkPositionCentered: Boolean
read FMarkPositionCentered write SetMarkPositionCentered default false;
property Radius: Integer read FRadius;
public public
constructor Create(AOwner: TComponent); override; constructor Create(AOwner: TComponent); override;
destructor Destroy; override; destructor Destroy; override;
@ -249,6 +253,8 @@ begin
Self.FExploded := FExploded; Self.FExploded := FExploded;
Self.FFixedRadius := FFixedRadius; Self.FFixedRadius := FFixedRadius;
Self.FInnerRadiusPercent := FInnerRadiusPercent; Self.FInnerRadiusPercent := FInnerRadiusPercent;
Self.FMarkDistancePercent := FMarkDistancePercent;
Self.FMarkPositionCentered := FMarkPositionCentered;
Self.FRotateLabels := FRotateLabels; Self.FRotateLabels := FRotateLabels;
end; end;
inherited Assign(ASource); inherited Assign(ASource);
@ -376,7 +382,7 @@ var
end; end;
end; end;
procedure DrawPieRing(ASlice: TPieSlice); procedure DrawRing(ASlice: TPieSlice);
var var
i: Integer; i: Integer;
a, angle1, angle2: Double; a, angle1, angle2: Double;
@ -433,9 +439,21 @@ var
AIndex := 0; AIndex := 0;
end; end;
procedure FindRegionIndexes(out AIndex14: Integer);
var
j: Integer;
begin
AIndex14 := 0;
for j := 0 to High(FSlices) do
if FSlices[j].FPrevAngle > PI_1_4 then begin
AIndex14 := j;
break;
end;
end;
var var
prevLabelPoly: TPointArray = nil; prevLabelPoly: TPointArray = nil;
i, iL: Integer; i, iL, i14: Integer;
begin begin
if IsEmpty then exit; if IsEmpty then exit;
@ -447,6 +465,7 @@ begin
if Depth > 0 then begin if Depth > 0 then begin
scaled_depth := ADrawer.Scale(Depth); scaled_depth := ADrawer.Scale(Depth);
FindLeftMostIndex(iL); FindLeftMostIndex(iL);
FindRegionIndexes(i14);
if FSlices[iL].FVisible then begin if FSlices[iL].FVisible then begin
if StartEdgeVisible(FSlices[iL]) then if StartEdgeVisible(FSlices[iL]) then
@ -477,8 +496,19 @@ begin
end; end;
// Draw arcs // Draw arcs
for i:= iL-1 downto 0 do if FSlices[iL].FNextAngle > PI_7_4 then dec(iL);
if FSlices[i14].FNextAngle > PI_7_4 then dec(i14);
for i := iL downto i14 do
DrawVisibleArc3D(FSlices[i]); DrawVisibleArc3D(FSlices[i]);
for i := 0 to i14 do begin
if EndEdgeVisible(FSlices[i]) then DrawEndEdge3D(FSlices[i]);
DrawVisibleArc3D(FSlices[i]);
end;
{
for i:= iL downto 0 do
DrawVisibleArc3D(FSlices[i]);
}
end; end;
ADrawer.SetPen(EdgePen); ADrawer.SetPen(EdgePen);
@ -491,7 +521,7 @@ begin
ps.FBase.X + FRadius, ps.FBase.Y + FRadius, ps.FBase.X + FRadius, ps.FBase.Y + FRadius,
RadToDeg16(ps.FPrevAngle), RadToDeg16(ps.Angle)) RadToDeg16(ps.FPrevAngle), RadToDeg16(ps.Angle))
else else
DrawPieRing(ps); DrawRing(ps);
end; end;
if not Marks.IsMarkLabelsVisible then exit; if not Marks.IsMarkLabelsVisible then exit;
@ -653,6 +683,13 @@ begin
UpdateParentChart; UpdateParentChart;
end; end;
procedure TCustomPieSeries.SetMarkPositionCentered(AValue: Boolean);
begin
if FMarkPositionCentered = AValue then exit;
FMarkPositionCentered := AValue;
UpdateParentChart;
end;
procedure TCustomPieSeries.SetMarkPositions(AValue: TPieMarkPositions); procedure TCustomPieSeries.SetMarkPositions(AValue: TPieMarkPositions);
begin begin
if FMarkPositions = AValue then exit; if FMarkPositions = AValue then exit;
@ -746,7 +783,7 @@ function TCustomPieSeries.TryRadius(ADrawer: IChartDrawer): TRect;
with ALabel do begin with ALabel do begin
FCenter := FAttachment; FCenter := FAttachment;
if not Marks.IsMarkLabelsVisible then exit; if not Marks.IsMarkLabelsVisible then exit;
FText := FormattedMark(AIndex); FText := FormattedMark(AIndex);
if FText = '' then exit; if FText = '' then exit;
if RotateLabels then if RotateLabels then
Marks.SetAdditionalAngle(AAngle); Marks.SetAdditionalAngle(AAngle);
@ -801,17 +838,21 @@ begin
ExpandRect( ExpandRect(
Result, FBase + Point(scaled_depth, -scaled_depth), Result, FBase + Point(scaled_depth, -scaled_depth),
FRadius, -FPrevAngle, -FNextAngle); FRadius, -FPrevAngle, -FNextAngle);
FLabel.FAttachment := EndPoint(a, FRadius) + FBase; if FMarkPositionCentered then
FLabel.FAttachment := EndPoint(a, (CalcInnerRadius + FRadius) div 2) + FBase
else
FLabel.FAttachment := EndPoint(a, FRadius) + FBase;
PrepareLabel(FLabel, i, a); PrepareLabel(FLabel, i, a);
end; end;
prevAngle := FNextAngle; prevAngle := FNextAngle;
end; end;
j += 1; inc(j);
end; end;
SetLength(FSlices, j); SetLength(FSlices, j);
InflateRect(Result, MARGIN, MARGIN); InflateRect(Result, MARGIN, MARGIN);
end; end;
{ TPolarSeries } { TPolarSeries }
procedure TPolarSeries.Assign(ASource: TPersistent); procedure TPolarSeries.Assign(ASource: TPersistent);

View File

@ -130,6 +130,7 @@ type
property FixedRadius; property FixedRadius;
property InnerRadiusPercent; property InnerRadiusPercent;
property MarkDistancePercent; property MarkDistancePercent;
property MarkPositionCentered;
property MarkPositions; property MarkPositions;
property Marks; property Marks;
property RotateLabels; property RotateLabels;