TAChart: Add new property "AngleRange" to TPieSeries to enable a "halfdonut series"

git-svn-id: trunk@62354 -
This commit is contained in:
wp 2019-12-08 18:22:21 +00:00
parent bdf8608839
commit 410090e60e
5 changed files with 93 additions and 37 deletions

View File

@ -401,16 +401,16 @@ object Form1: TForm1
TabOrder = 12
end
object seViewAngle: TSpinEdit
AnchorSideLeft.Control = lblViewAngle
AnchorSideLeft.Side = asrBottom
AnchorSideLeft.Control = seAngleRange
AnchorSideTop.Control = seDistance
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = cmbOrientation
AnchorSideRight.Side = asrBottom
Left = 549
Left = 562
Height = 23
Top = 64
Width = 62
BorderSpacing.Right = 6
Anchors = [akTop, akRight]
Enabled = False
MaxValue = 89
OnChange = seViewAngleChange
@ -418,14 +418,15 @@ object Form1: TForm1
Value = 60
end
object lblViewAngle: TLabel
AnchorSideLeft.Control = seDepth
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = seViewAngle
AnchorSideTop.Side = asrCenter
Left = 484
AnchorSideRight.Control = seViewAngle
Left = 497
Height = 15
Top = 68
Width = 57
Anchors = [akTop, akRight]
BorderSpacing.Left = 12
BorderSpacing.Right = 8
Caption = 'View angle'
@ -433,17 +434,17 @@ object Form1: TForm1
ParentColor = False
end
object cmbOrientation: TComboBox
AnchorSideLeft.Control = lblViewAngle
AnchorSideLeft.Control = seDepthBrightnessDelta
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = cbMarkAttachment
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = seViewAngle
AnchorSideRight.Side = asrBottom
Left = 484
Left = 496
Height = 23
Top = 93
Width = 127
Anchors = [akTop, akLeft, akRight]
Width = 128
AutoSize = False
BorderSpacing.Left = 24
BorderSpacing.Bottom = 8
Enabled = False
ItemHeight = 15
@ -458,6 +459,36 @@ object Form1: TForm1
TabOrder = 14
Text = 'normal'
end
object lblAngleRange: TLabel
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = seAngleRange
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = seAngleRange
Left = 493
Height = 15
Top = 39
Width = 64
Anchors = [akTop, akRight]
BorderSpacing.Left = 12
BorderSpacing.Right = 8
Caption = 'Angle range'
ParentColor = False
end
object seAngleRange: TSpinEdit
AnchorSideTop.Control = seStartAngle
AnchorSideRight.Control = cmbOrientation
AnchorSideRight.Side = asrBottom
Left = 565
Height = 23
Top = 35
Width = 59
Anchors = [akTop, akRight]
MaxValue = 360
MinValue = 1
OnChange = seAngleRangeChange
TabOrder = 15
Value = 360
end
end
end
object tsPolar: TTabSheet
@ -601,7 +632,7 @@ object Form1: TForm1
'0|7|?|'
'0|3|?|'
'0|1|?|'
'0.20000000000000001|0.20000000000000001|?|'
'0.2|0.2|?|'
'0|1|?|'
)
left = 64

View File

@ -33,6 +33,7 @@ type
lblViewAngle: TLabel;
lblDistance: TLabel;
lblStartAngle: TLabel;
lblAngleRange: TLabel;
seDepth: TSpinEdit;
seViewAngle: TSpinEdit;
seDepthBrightnessDelta: TSpinEdit;
@ -49,6 +50,7 @@ type
RandomChartSource1: TRandomChartSource;
sbTransparency: TScrollBar;
seStartAngle: TSpinEdit;
seAngleRange: TSpinEdit;
seWords: TSpinEdit;
seLabelAngle: TSpinEdit;
seInnerRadius: TSpinEdit;
@ -70,6 +72,7 @@ type
procedure seDepthBrightnessDeltaChange(Sender: TObject);
procedure seDepthChange(Sender: TObject);
procedure seDistanceChange(Sender: TObject);
procedure seAngleRangeChange(Sender: TObject);
procedure seInnerRadiusChange(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure sbTransparencyChange(Sender: TObject);
@ -182,6 +185,11 @@ begin
ChartPiePieSeries1.Marks.Distance := seDistance.Value;
end;
procedure TForm1.seAngleRangeChange(Sender: TObject);
begin
ChartPiePieSeries1.AngleRange := seAngleRange.Value;
end;
procedure TForm1.seInnerRadiusChange(Sender: TObject);
begin
ChartPiePieSeries1.InnerRadiusPercent := seInnerRadius.Value;

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions BuildModesCount="1">
<ProjectOptions>
<Version Value="12"/>
<PathDelim Value="\"/>
<General>
@ -12,46 +12,46 @@
<EnableI18N LFM="False"/>
</i18n>
<BuildModes>
<Item1 Name="default" Default="True"/>
<Item Name="default" Default="True"/>
</BuildModes>
<PublishOptions>
<Version Value="2"/>
</PublishOptions>
<RunParams>
<FormatVersion Value="2"/>
<Modes Count="1">
<Mode0 Name="default"/>
<Modes>
<Mode Name="default"/>
</Modes>
</RunParams>
<RequiredPackages Count="4">
<Item1>
<RequiredPackages>
<Item>
<PackageName Value="LCLBase"/>
<MinVersion Major="1" Release="1" Valid="True"/>
</Item1>
<Item2>
</Item>
<Item>
<PackageName Value="TAChartLazarusPkg"/>
<MinVersion Major="1" Valid="True"/>
</Item2>
<Item3>
</Item>
<Item>
<PackageName Value="LazControls"/>
<MinVersion Valid="True"/>
</Item3>
<Item4>
</Item>
<Item>
<PackageName Value="LCL"/>
</Item4>
</Item>
</RequiredPackages>
<Units Count="2">
<Unit0>
<Units>
<Unit>
<Filename Value="radialdemo.lpr"/>
<IsPartOfProject Value="True"/>
</Unit0>
<Unit1>
</Unit>
<Unit>
<Filename Value="main.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="Form1"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
</Unit1>
</Unit>
</Units>
</ProjectOptions>
<CompilerOptions>
@ -73,16 +73,16 @@
</Linking>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">
<Item1>
<Exceptions>
<Item>
<Name Value="EAbort"/>
</Item1>
<Item2>
</Item>
<Item>
<Name Value="ECodetoolError"/>
</Item2>
<Item3>
</Item>
<Item>
<Name Value="EFOpenError"/>
</Item3>
</Item>
</Exceptions>
</Debugging>
</CONFIG>

View File

@ -81,6 +81,7 @@ type
FInnerRadiusPercent: Integer;
FSlices: array of TPieSlice;
FStartAngle: Integer;
FAngleRange: Integer;
FEdgePen: TPen;
FExploded: Boolean;
FFixedRadius: TChartDistance;
@ -89,6 +90,7 @@ type
function FixAspectRatio(P: TPoint): TPoint;
function GetViewAngle: Integer;
procedure Measure(ADrawer: IChartDrawer);
procedure SetAngleRange(AValue: Integer);
procedure SetEdgePen(AValue: TPen);
procedure SetExploded(AValue: Boolean);
procedure SetFixedRadius(AValue: TChartDistance);
@ -115,6 +117,8 @@ type
property Radius: Integer read FRadius;
property StartAngle: Integer
read FStartAngle write SetStartAngle default 0;
property AngleRange: Integer
read FAngleRange write SetAngleRange default 360;
property ViewAngle: Integer
read GetViewAngle write SetViewAngle default 60;
property OnCustomDrawPie: TCustomDrawPieEvent
@ -333,6 +337,7 @@ constructor TCustomPieSeries.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
ViewAngle := 60;
FAngleRange := 360;
FEdgePen := TPen.Create;
FEdgePen.OnChange := @StyleChanged;
@ -824,6 +829,16 @@ begin
end;
end;
procedure TCustomPieSeries.SetAngleRange(AValue: Integer);
begin
if FAngleRange = AValue then exit;
if AValue = 0 then
FAngleRange := 360
else
FAngleRange := EnsureRange(AValue, 1, 360);
UpdateParentChart;
end;
procedure TCustomPieSeries.SetEdgePen(AValue: TPen);
begin
if FEdgePen = AValue then exit;
@ -1144,6 +1159,7 @@ begin
total := Source.ValuesTotal;
if total = 0 then
exit;
total := total * 360 / FAngleRange;
prevAngle := start_angle;
for i := 0 to Count - 1 do begin
di := Source[i];

View File

@ -145,6 +145,7 @@ type
public
property Radius;
published
property AngleRange;
property EdgePen;
property Depth;
property DepthBrightnessDelta;