TAChart: Add "Position" tab to the axis demo

git-svn-id: trunk@37508 -
This commit is contained in:
ask 2012-06-04 10:13:29 +00:00
parent 2ee0e2bafb
commit 51162a24b6
3 changed files with 264 additions and 5 deletions

View File

@ -50,6 +50,7 @@
<Filename Value="main.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="Form1"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="Main"/>
</Unit1>

View File

@ -8,7 +8,7 @@ object Form1: TForm1
ClientWidth = 533
OnCreate = FormCreate
Position = poScreenCenter
LCLVersion = '0.9.31'
LCLVersion = '1.1'
object PageControl1: TPageControl
Left = 0
Height = 430
@ -308,6 +308,196 @@ object Form1: TForm1
ParentColor = False
end
end
object tsPosition: TTabSheet
Caption = 'Position'
ClientHeight = 404
ClientWidth = 525
object ChartPosition: TChart
Left = 0
Height = 404
Top = 0
Width = 395
AxisList = <
item
Grid.Visible = False
Intervals.Tolerance = 1
AxisPen.Visible = True
Marks.LabelBrush.Style = bsSolid
Minors = <>
Position = 50
end
item
Grid.Visible = False
Intervals.Tolerance = 1
Alignment = calBottom
AxisPen.Visible = True
Marks.LabelBrush.Style = bsSolid
Minors = <>
Position = 50
end
item
Grid.Color = clGray
Intervals.Tolerance = 1
Visible = False
Minors = <>
Title.LabelFont.Orientation = 900
end
item
Grid.Color = clGray
Intervals.Tolerance = 1
Visible = False
Alignment = calBottom
Minors = <>
end>
BackColor = clWhite
Foot.Brush.Color = clBtnFace
Foot.Font.Color = clBlue
Title.Brush.Color = clBtnFace
Title.Font.Color = clBlue
Title.Text.Strings = (
'TAChart'
)
Align = alClient
Color = clWhite
ParentColor = False
object ChartPositionFuncSeries1: TFuncSeries
Extent.UseXMax = True
Extent.UseXMin = True
Extent.UseYMax = True
Extent.UseYMin = True
Extent.XMax = 10
Extent.XMin = -10
Extent.YMax = 3
Extent.YMin = -3
OnCalculate = ChartPositionFuncSeries1Calculate
Pen.Color = clTeal
Pen.Width = 2
end
end
object pnlPosition: TPanel
Left = 395
Height = 404
Top = 0
Width = 130
Align = alRight
Caption = 'pnlPosition'
ClientHeight = 404
ClientWidth = 130
TabOrder = 1
object gbPositionX: TGroupBox
Left = 1
Height = 121
Top = 1
Width = 128
Align = alTop
Caption = ' X axis '
ClientHeight = 103
ClientWidth = 124
TabOrder = 0
object seXPosition: TSpinEdit
Left = 6
Height = 21
Top = 21
Width = 90
OnChange = seXPositionChange
TabOrder = 0
Value = 50
end
object lblPositionX: TLabel
Left = 6
Height = 14
Top = 1
Width = 42
Caption = 'Position:'
ParentColor = False
end
object cbStaticX: TCheckBox
Left = 6
Height = 17
Top = 49
Width = 97
Caption = 'Show static axis'
OnChange = cbStaticXChange
TabOrder = 1
end
object rbPositionBottom: TRadioButton
Left = 6
Height = 17
Top = 73
Width = 54
Caption = 'Bottom'
Checked = True
OnChange = rbPositionBottomChange
TabOrder = 3
TabStop = True
end
object rbPositionTop: TRadioButton
Left = 70
Height = 17
Top = 73
Width = 38
Caption = 'Top'
TabOrder = 2
end
end
object gbPositionY: TGroupBox
Left = 1
Height = 116
Top = 122
Width = 128
Align = alTop
Caption = ' Y axis '
ClientHeight = 98
ClientWidth = 124
TabOrder = 1
object lblPositionY: TLabel
Left = 6
Height = 14
Top = 1
Width = 42
Caption = 'Position:'
ParentColor = False
end
object cbStaticY: TCheckBox
Left = 6
Height = 17
Top = 49
Width = 97
Caption = 'Show static axis'
OnChange = cbStaticYChange
TabOrder = 0
end
object seYPosition: TSpinEdit
Left = 6
Height = 21
Top = 20
Width = 90
OnChange = seYPositionChange
TabOrder = 1
Value = 50
end
object rbPositionRight: TRadioButton
Left = 70
Height = 17
Top = 76
Width = 45
Caption = 'Right'
TabOrder = 2
end
object rbPositionLeft: TRadioButton
Left = 6
Height = 17
Top = 76
Width = 39
Caption = 'Left'
Checked = True
OnChange = rbPositionLeftChange
TabOrder = 3
TabStop = True
end
end
end
end
end
object lcsMarks: TListChartSource
DataPoints.Strings = (

View File

@ -5,9 +5,9 @@ unit Main;
interface
uses
ComCtrls, ExtCtrls, Forms, TACustomSource, TAFuncSeries, TAGraph,
TAIntervalSources, TASeries, TASources, TAStyles, TATools, TATransformations,
TAChartAxis;
ComCtrls, ExtCtrls, Forms, Spin, StdCtrls, TACustomSource, TAFuncSeries,
TAGraph, TAIntervalSources, TASeries, TASources, TAStyles, TATools,
TATransformations, TAChartAxis, Classes;
type
@ -18,22 +18,38 @@ type
catTAutoAutoScaleAxisTransform1: TAutoScaleAxisTransform;
catTAutoScaleAxisTransform1: TAutoScaleAxisTransform;
catTFahrToCel: TLinearAxisTransform;
cbStaticY: TCheckBox;
ChartPosition: TChart;
ChartIntervals: TChart;
ChartAxisGroup: TChart;
ChartCustomMarks: TChart;
ChartCustomMarksBarSeries1: TBarSeries;
ChartDateTime: TChart;
ChartDateTimeLineSeries1: TLineSeries;
ChartPositionFuncSeries1: TFuncSeries;
ChartSubmarks: TChart;
ChartSubmarksLineSeries1: TLineSeries;
ChartToolset1ZoomIn: TZoomClickTool;
ChartToolset1ZoomOut: TZoomClickTool;
ChartToolsetDateTime: TChartToolset;
cbStaticX: TCheckBox;
csStripes: TChartStyles;
DateTimeIntervalChartSource1: TDateTimeIntervalChartSource;
gbPositionX: TGroupBox;
gbPositionY: TGroupBox;
lblPositionX: TLabel;
lblPositionY: TLabel;
lcsMarks: TListChartSource;
PageControl1: TPageControl;
pnlPosition: TPanel;
rbPositionBottom: TRadioButton;
rbPositionLeft: TRadioButton;
rbPositionTop: TRadioButton;
rbPositionRight: TRadioButton;
rcsDates: TRandomChartSource;
seXPosition: TSpinEdit;
seYPosition: TSpinEdit;
tsPosition: TTabSheet;
tsIntervals: TTabSheet;
tsAxisGroup: TTabSheet;
tsCustomMarks: TTabSheet;
@ -42,8 +58,16 @@ type
udcsGraph: TUserDefinedChartSource;
udcsMain: TUserDefinedChartSource;
udcsSub: TUserDefinedChartSource;
procedure cbStaticXChange(Sender: TObject);
procedure cbStaticYChange(Sender: TObject);
procedure ChartCustomMarksAxisList1MarkToText(var AText: String; AMark: Double);
procedure ChartPositionFuncSeries1Calculate(const AX: Double; out
AY: Double);
procedure FormCreate(Sender: TObject);
procedure rbPositionBottomChange(Sender: TObject);
procedure rbPositionLeftChange(Sender: TObject);
procedure seXPositionChange(Sender: TObject);
procedure seYPositionChange(Sender: TObject);
procedure udcsGraphGetChartDataItem(ASource: TUserDefinedChartSource;
AIndex: Integer; var AItem: TChartDataItem);
procedure udcsMainGetChartDataItem(ASource: TUserDefinedChartSource;
@ -58,18 +82,34 @@ var
implementation
uses
SysUtils, TAChartUtils;
SysUtils, TAChartAxisUtils, TAChartUtils;
{$R *.lfm}
{ TForm1 }
procedure TForm1.cbStaticXChange(Sender: TObject);
begin
ChartPosition.AxisList[3].Visible := cbStaticX.Checked;
end;
procedure TForm1.cbStaticYChange(Sender: TObject);
begin
ChartPosition.AxisList[2].Visible := cbStaticY.Checked;
end;
procedure TForm1.ChartCustomMarksAxisList1MarkToText(var AText: String; AMark: Double);
begin
if AMark = 3 then
AText := '*' + AText + '*';
end;
procedure TForm1.ChartPositionFuncSeries1Calculate(
const AX: Double; out AY: Double);
begin
AY := Sin(AX / 3) + Cos(AX) * 2;
end;
procedure TForm1.FormCreate(Sender: TObject);
const
COLORS: array [1..5] of Integer =
@ -118,6 +158,34 @@ begin
end;
end;
procedure TForm1.rbPositionBottomChange(Sender: TObject);
begin
with ChartPosition.AxisList[1] do
if rbPositionBottom.Checked then
Alignment := calBottom
else
Alignment := calTop;
end;
procedure TForm1.rbPositionLeftChange(Sender: TObject);
begin
with ChartPosition.AxisList[0] do
if rbPositionLeft.Checked then
Alignment := calLeft
else
Alignment := calRight;
end;
procedure TForm1.seXPositionChange(Sender: TObject);
begin
ChartPosition.AxisList[1].Position := seXPosition.Value;
end;
procedure TForm1.seYPositionChange(Sender: TObject);
begin
ChartPosition.AxisList[0].Position := seYPosition.Value;
end;
procedure TForm1.udcsGraphGetChartDataItem(ASource: TUserDefinedChartSource;
AIndex: Integer; var AItem: TChartDataItem);
begin