TAChart: Improved version of the new barseriestools demo.

git-svn-id: trunk@53903 -
This commit is contained in:
wp 2017-01-09 11:23:14 +00:00
parent a11063c60e
commit f9244f936d
2 changed files with 31 additions and 13 deletions

View File

@ -50,24 +50,24 @@ object MainForm: TMainForm
OnChange = CbHorizontalChange OnChange = CbHorizontalChange
TabOrder = 0 TabOrder = 0
end end
object CbStacked: TCheckBox object Cb100Percent: TCheckBox
AnchorSideLeft.Control = CbHorizontal AnchorSideLeft.Control = CbHorizontal
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = CbHorizontal AnchorSideTop.Control = CbHorizontal
Left = 95 Left = 95
Height = 19 Height = 19
Top = 0 Top = 0
Width = 61 Width = 48
BorderSpacing.Left = 16 BorderSpacing.Left = 16
Caption = 'Stacked' Caption = '100%'
OnChange = CbStackedChange OnChange = Cb100PercentChange
TabOrder = 1 TabOrder = 1
end end
object TargetPanel: TPanel object TargetPanel: TPanel
AnchorSideLeft.Control = CbStacked AnchorSideLeft.Control = Cb100Percent
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = CbHorizontal AnchorSideTop.Control = CbHorizontal
Left = 196 Left = 183
Height = 21 Height = 21
Top = 0 Top = 0
Width = 203 Width = 203
@ -148,7 +148,7 @@ object MainForm: TMainForm
Alignment = calBottom Alignment = calBottom
AxisPen.Visible = True AxisPen.Visible = True
Marks.Format = '%2:s' Marks.Format = '%2:s'
Marks.Source = ListChartSourceBLUE Marks.Source = ListChartSourceLABELS
Marks.Style = smsLabel Marks.Style = smsLabel
Minors = <> Minors = <>
ZPosition = 1 ZPosition = 1
@ -258,4 +258,8 @@ object MainForm: TMainForm
left = 120 left = 120
top = 144 top = 144
end end
object ListChartSourceLABELS: TListChartSource
left = 120
top = 216
end
end end

View File

@ -24,9 +24,10 @@ type
DataPointClickTool: TDataPointClickTool; DataPointClickTool: TDataPointClickTool;
DataPointHintTool: TDataPointHintTool; DataPointHintTool: TDataPointHintTool;
CbHorizontal: TCheckBox; CbHorizontal: TCheckBox;
CbStacked: TCheckBox; Cb100Percent: TCheckBox;
LblToolTargets: TLabel; LblToolTargets: TLabel;
LblInfo: TLabel; LblInfo: TLabel;
ListChartSourceLABELS: TListChartSource;
ListChartSourceREDYELLOW: TListChartSource; ListChartSourceREDYELLOW: TListChartSource;
ListChartSourceBLUE: TListChartSource; ListChartSourceBLUE: TListChartSource;
Log: TMemo; Log: TMemo;
@ -45,7 +46,7 @@ type
procedure DataPointHintToolHint(ATool: TDataPointHintTool; procedure DataPointHintToolHint(ATool: TDataPointHintTool;
const APoint: TPoint; var AHint: String); const APoint: TPoint; var AHint: String);
procedure CbHorizontalChange(Sender: TObject); procedure CbHorizontalChange(Sender: TObject);
procedure CbStackedChange(Sender: TObject); procedure Cb100PercentChange(Sender: TObject);
procedure FormCreate(Sender: TObject); procedure FormCreate(Sender: TObject);
procedure ToolTargetChanged(Sender: TObject); procedure ToolTargetChanged(Sender: TObject);
private private
@ -75,18 +76,30 @@ begin
TChartSeries(Chart.Series[0]).AxisIndexY := 1; TChartSeries(Chart.Series[0]).AxisIndexY := 1;
TChartSeries(Chart.Series[1]).AxisIndexX := 0; TChartSeries(Chart.Series[1]).AxisIndexX := 0;
TChartSeries(Chart.Series[1]).AxisIndexY := 1; TChartSeries(Chart.Series[1]).AxisIndexY := 1;
Chart.LeftAxis.Marks.Source := ListChartSourceLABELS;
Chart.LeftAxis.Marks.Style := smsLabel;
Chart.BottomAxis.Marks.Source := nil;
Chart.BottomAxis.Marks.Style := smsValue;
Chart.Margins.Left := 0;
Chart.Margins.Bottom := 4;
end else end else
begin begin
TChartSeries(Chart.Series[0]).AxisIndexX := 1; TChartSeries(Chart.Series[0]).AxisIndexX := 1;
TChartSeries(Chart.Series[0]).AxisIndexY := 0; TChartSeries(Chart.Series[0]).AxisIndexY := 0;
TChartSeries(Chart.Series[1]).AxisIndexX := 1; TChartSeries(Chart.Series[1]).AxisIndexX := 1;
TChartSeries(Chart.Series[1]).AxisIndexY := 0; TChartSeries(Chart.Series[1]).AxisIndexY := 0;
Chart.BottomAxis.Marks.Source := ListChartSourceLABELS;
Chart.BottomAxis.Marks.Style := smsLabel;
Chart.LeftAxis.Marks.Source := nil;
Chart.LeftAxis.Marks.Style := smsValue;
Chart.Margins.Bottom := 0;
Chart.Margins.Left := 4;
end; end;
end; end;
procedure TMainForm.CbStackedChange(Sender: TObject); procedure TMainForm.Cb100PercentChange(Sender: TObject);
begin begin
CalculatedChartSource.Percentage := CbStacked.Checked; CalculatedChartSource.Percentage := Cb100Percent.Checked;
end; end;
procedure TMainForm.DataPointClickToolPointClick(ATool: TChartTool; procedure TMainForm.DataPointClickToolPointClick(ATool: TChartTool;
@ -163,8 +176,9 @@ var
i: Integer; i: Integer;
begin begin
for i:=0 to 5 do begin for i:=0 to 5 do begin
ListChartSourceRedYellow.AddXYList(i, [random*50, random*60], char(ord('A') + i)); ListChartSourceRedYellow.AddXYList(i, [random*50, random*60]);
ListChartSourceBlue.Add(i, Random*80, char(ord('A') + i)); ListChartSourceBlue.Add(i, Random*80);
ListChartSourceLABELS.Add(i, i, char(ord('A') + i));
end; end;
end; end;