TAChart: Add pie series demo to datapointtooldemo.

git-svn-id: trunk@58472 -
This commit is contained in:
wp 2018-07-09 15:01:48 +00:00
parent 4d7ff08e66
commit c9aed21706
3 changed files with 56 additions and 13 deletions

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="10"/>
<Version Value="11"/>
<PathDelim Value="\"/>
<General>
<SessionStorage Value="InProjectDir"/>
@ -9,7 +9,6 @@
<Title Value="datapointtooldemo"/>
<ResourceType Value="res"/>
<UseXPManifest Value="True"/>
<Icon Value="0"/>
</General>
<BuildModes Count="1">
<Item1 Name="Default" Default="True"/>
@ -18,9 +17,10 @@
<Version Value="2"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
</local>
<FormatVersion Value="2"/>
<Modes Count="1">
<Mode0 Name="default"/>
</Modes>
</RunParams>
<RequiredPackages Count="2">
<Item1>

View File

@ -30,13 +30,14 @@ object MainForm: TMainForm
'Field series'
'Function series'
'Constant line'
'Pie series'
)
Align = alClient
TabOrder = 0
object Chart: TChart
Left = 2
Height = 302
Top = 43
Height = 282
Top = 63
Width = 633
AutoFocus = True
AxisList = <
@ -87,6 +88,7 @@ object MainForm: TMainForm
BarBrush.Color = clRed
BarWidthStyle = bwPercentMin
Source = ListChartSource
Stacked = True
Styles = ChartStyles
end
object AreaSeries: TAreaSeries
@ -184,6 +186,9 @@ object MainForm: TMainForm
Pointer.VertSize = 5
Pointer.Visible = False
end
object PieSeries: TPieSeries
Title = 'Pie series'
end
end
end
object Panel1: TPanel
@ -226,7 +231,7 @@ object MainForm: TMainForm
end
object LblNOTE: TLabel
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = Label2
AnchorSideTop.Control = LblUSAGE
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
@ -242,7 +247,7 @@ object MainForm: TMainForm
ParentColor = False
WordWrap = True
end
object Label2: TLabel
object LblUSAGE: TLabel
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = CbDragXY
AnchorSideTop.Side = asrBottom
@ -315,6 +320,9 @@ object MainForm: TMainForm
OnDraw = CrosshairToolDraw
Size = 12
end
object PieSeriesDatapointDragTool: TDataPointDragTool
Shift = [ssLeft]
end
end
object ChartStyles: TChartStyles
Styles = <

View File

@ -22,6 +22,8 @@ type
BoxWhiskerSeries: TBoxAndWhiskerSeries;
BubbleSeries: TBubbleSeries;
BSplineSeries: TBSplineSeries;
PieSeriesDatapointDragTool: TDataPointDragTool;
PieSeries: TPieSeries;
FitSeries: TFitSeries;
FieldSeries: TFieldSeries;
FuncSeries: TFuncSeries;
@ -35,7 +37,7 @@ type
CbDragXY: TCheckBox;
DatapointInfo: TLabel;
LblNOTE: TLabel;
Label2: TLabel;
LblUSAGE: TLabel;
ListChartSource: TListChartSource;
CrosshairTool: TDataPointCrosshairTool;
HintTool: TDataPointHintTool;
@ -75,12 +77,16 @@ implementation
{$R *.lfm}
uses
TALegend;
{ TMainForm }
procedure TMainForm.CbCandleStickChange(Sender: TObject);
begin
if CbCandleStick.Checked then
OHLCSeries.Mode := mCandleStick else
OHLCSeries.Mode := mCandleStick
else
OHLCSeries.Mode := mOHLC;
end;
@ -206,6 +212,15 @@ begin
FieldSeries.AddVector(x, y1, x2, y2);
end;
PieSeries.ListSource.Clear;
for i:=0 to 4 do begin
y1 := Random*10;
PieSeries.AddXY(0, y1, 'Item ' + IntToStr(i+1));
end;
PieSeries.Legend.Multiplicity := lmPoint;
PieSeries.Marks.Style := smsLabel;
PieSeries.Exploded := true;
LineSeries.Index := 0;
BarSeries.Index := 1;
AreaSeries.Index := 2;
@ -219,6 +234,7 @@ begin
FieldSeries.Index := 10;
FuncSeries.Index := 11;
ConstantLineSeries.Index := 12;
PieSeries.Index := 13;
TabControlChange(nil);
DatapointInfo.Caption := '';
@ -255,7 +271,15 @@ begin
ATool.NearestGraphPoint.X, ATool.NearestGraphPoint.Y
])
else
if (ATool.PointIndex > -1) and (ATool.YIndex > -1) then
if (ATool.PointIndex > -1) and (ser.Source.YCount = 1) then
Result := Format('"%s": Point index %d, x = %.2f, y = %.2f', [
ser.Title,
ATool.PointIndex,
ser.XValue[ATool.PointIndex],
ser.YValue[ATool.PointIndex]
])
else
if (ATool.PointIndex > -1) and (ser.Source.YCount > 1) and (ATool.YIndex > -1) then
Result := Format('"%s": Point index %d, x = %.2f, y = %.2f (y index %d)', [
ser.Title,
ATool.PointIndex,
@ -290,6 +314,7 @@ begin
BubbleSeriesDatapointDragTool.Enabled := TabControl.TabIndex = BubbleSeries.Index;
FieldSeriesDatapointDragTool.Enabled := TabControl.TabIndex = FieldSeries.Index;
PieSeriesDatapointDragTool.Enabled := TabControl.TabIndex = PieSeries.Index;
DataPointDragTool.Enabled := not
(BubbleSeriesDatapointDragTool.Enabled or FieldSeriesDatapointDragtool.Enabled);
@ -298,6 +323,9 @@ begin
else
if FieldSeriesDatapointDragTool.Enabled then
FieldSeriesDatapointDragTool.AffectedSeries := s
else
if PieSeriesDatapointDragTool.Enabled then
PieSeriesDatapointDragtool.AffectedSeries := s
else
DatapointDragtool.AffectedSeries := s;
@ -307,6 +335,11 @@ begin
Chart.LeftAxis.Range.UseMax := ConstantLineSeries.Active;
Chart.LeftAxis.Range.UseMin := ConstantLineSeries.Active;
if PieSeries.Active then
LblUsage.Caption := StringReplace(LblUsage.Caption, 'datapoint', 'pie', [])
else
LblUsage.Caption := StringReplace(LblUsage.Caption, 'pie', 'datapoint', []);
s := '';
if LineSeries.Active or BarSeries.Active or AreaSeries.Active then begin
s := 'These are stacked series, i.e. they share the same x ' +
@ -326,7 +359,9 @@ begin
'Overlapping bubbles may be detected erroneously.';
if s <> '' then
LblNOTE.Caption := 'NOTE:' + LineEnding + s;
LblNote.Visible := (s <> '');
LblNOTE.Visible := (s <> '');
CbDragXY.Enabled := not PieSeries.Active;
end;
end.