mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-08 10:39:15 +02:00
TAChart: Update funcdemo
* Add user-drawn series demo * Remove workarounds for object inspector bugs with subproperty events git-svn-id: trunk@21827 -
This commit is contained in:
parent
e14b665868
commit
da2c5cb914
@ -42,8 +42,8 @@
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="main.pas"/>
|
||||
<ComponentName Value="Form1"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="Form1"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="main"/>
|
||||
</Unit1>
|
||||
|
@ -6,20 +6,28 @@ object Form1: TForm1
|
||||
Caption = 'Form1'
|
||||
ClientHeight = 362
|
||||
ClientWidth = 461
|
||||
OnCreate = FormCreate
|
||||
Position = poScreenCenter
|
||||
LCLVersion = '0.9.27'
|
||||
LCLVersion = '0.9.29'
|
||||
object Chart1: TChart
|
||||
Left = 0
|
||||
Height = 362
|
||||
Top = 0
|
||||
Width = 461
|
||||
BottomAxis.Grid.Style = psDot
|
||||
AxisList = <
|
||||
item
|
||||
Alignment = calLeft
|
||||
Offset = 0
|
||||
Scale = 1
|
||||
Title.Font.Orientation = 900
|
||||
end
|
||||
item
|
||||
Alignment = calBottom
|
||||
Offset = 0
|
||||
Scale = 1
|
||||
end>
|
||||
ExpandPercentage = 10
|
||||
Foot.Brush.Color = clBtnFace
|
||||
Foot.Font.Color = clBlue
|
||||
LeftAxis.Grid.Style = psDot
|
||||
LeftAxis.Title.Angle = 90
|
||||
Legend.Visible = True
|
||||
Title.Brush.Color = clBtnFace
|
||||
Title.Font.Color = clBlue
|
||||
@ -37,6 +45,7 @@ object Form1: TForm1
|
||||
Extent.UseYMin = True
|
||||
Extent.UseXMax = True
|
||||
Extent.UseYMax = True
|
||||
OnCalculate = Chart1FuncSeries1Calculate
|
||||
Pen.Color = clOlive
|
||||
Pen.Width = 2
|
||||
Step = 4
|
||||
@ -59,8 +68,12 @@ object Form1: TForm1
|
||||
SeriesColor = clMoneyGreen
|
||||
Source = UserDefinedChartSource1
|
||||
end
|
||||
object Chart1UserDrawnSeries1: TUserDrawnSeries
|
||||
OnDraw = Chart1UserDrawnSeries1Draw
|
||||
end
|
||||
end
|
||||
object UserDefinedChartSource1: TUserDefinedChartSource
|
||||
OnGetChartDataItem = UserDefinedChartSource1GetChartDataItem
|
||||
PointsNumber = 14
|
||||
left = 135
|
||||
top = 114
|
||||
|
@ -3,24 +3,28 @@
|
||||
LazarusResources.Add('TForm1','FORMDATA',[
|
||||
'TPF0'#6'TForm1'#5'Form1'#4'Left'#3'"'#1#6'Height'#3'j'#1#3'Top'#3#152#0#5'Wi'
|
||||
+'dth'#3#205#1#7'Caption'#6#5'Form1'#12'ClientHeight'#3'j'#1#11'ClientWidth'#3
|
||||
+#205#1#8'OnCreate'#7#10'FormCreate'#8'Position'#7#14'poScreenCenter'#10'LCLV'
|
||||
+'ersion'#6#6'0.9.27'#0#6'TChart'#6'Chart1'#4'Left'#2#0#6'Height'#3'j'#1#3'To'
|
||||
+'p'#2#0#5'Width'#3#205#1#21'BottomAxis.Grid.Style'#7#5'psDot'#16'ExpandPerce'
|
||||
+'ntage'#2#10#16'Foot.Brush.Color'#7#9'clBtnFace'#15'Foot.Font.Color'#7#6'clB'
|
||||
+'lue'#19'LeftAxis.Grid.Style'#7#5'psDot'#20'LeftAxis.Title.Angle'#2'Z'#14'Le'
|
||||
+'gend.Visible'#9#17'Title.Brush.Color'#7#9'clBtnFace'#16'Title.Font.Color'#7
|
||||
+#6'clBlue'#18'Title.Text.Strings'#1#6#7'TAChart'#0#5'Align'#7#8'alClient'#11
|
||||
+'ParentColor'#8#0#11'TFuncSeries'#17'Chart1FuncSeries1'#11'Extent.XMin'#5#0
|
||||
+#248'(\'#143#194#245#200#1#192#11'Extent.YMin'#5#0#0#0#0#0#0#0#128#255#191#11
|
||||
+'Extent.XMax'#5#0#248'(\'#143#194#245#200#1'@'#11'Extent.YMax'#5#0#0#0#0#0#0
|
||||
+#0#128#255'?'#14'Extent.UseXMin'#9#14'Extent.UseYMin'#9#14'Extent.UseXMax'#9
|
||||
+#14'Extent.UseYMax'#9#9'Pen.Color'#7#7'clOlive'#9'Pen.Width'#2#2#4'Step'#2#4
|
||||
+#5'Title'#6#6'Sin(x)'#0#0#5'TLine'#11'Chart1XAxis'#12'ShowInLegend'#8#8'Posi'
|
||||
+'tion'#5#0#0#0#0#0#0#0#0#0#0#11'SeriesColor'#7#7'clBlack'#0#0#5'TLine'#11'Ch'
|
||||
+'art1YAxis'#12'ShowInLegend'#8#9'LineStyle'#7#10'lsVertical'#8'Position'#5#0
|
||||
+#0#0#0#0#0#0#0#0#0#11'SeriesColor'#7#7'clBlack'#0#0#10'TBarSeries'#16'Chart1'
|
||||
+'BarSeries1'#5'Title'#6#6'Cos(x)'#14'BarBrush.Color'#7#12'clMoneyGreen'#11'S'
|
||||
+'eriesColor'#7#12'clMoneyGreen'#6'Source'#7#23'UserDefinedChartSource1'#0#0#0
|
||||
+#23'TUserDefinedChartSource'#23'UserDefinedChartSource1'#12'PointsNumber'#2
|
||||
+#14#4'left'#3#135#0#3'top'#2'r'#0#0#0
|
||||
+#205#1#8'Position'#7#14'poScreenCenter'#10'LCLVersion'#6#6'0.9.29'#0#6'TChar'
|
||||
+'t'#6'Chart1'#4'Left'#2#0#6'Height'#3'j'#1#3'Top'#2#0#5'Width'#3#205#1#8'Axi'
|
||||
+'sList'#14#1#9'Alignment'#7#7'calLeft'#6'Offset'#5#0#0#0#0#0#0#0#0#0#0#5'Sca'
|
||||
+'le'#5#0#0#0#0#0#0#0#128#255'?'#22'Title.Font.Orientation'#3#132#3#0#1#9'Ali'
|
||||
+'gnment'#7#9'calBottom'#6'Offset'#5#0#0#0#0#0#0#0#0#0#0#5'Scale'#5#0#0#0#0#0
|
||||
+#0#0#128#255'?'#0#0#16'ExpandPercentage'#2#10#16'Foot.Brush.Color'#7#9'clBtn'
|
||||
+'Face'#15'Foot.Font.Color'#7#6'clBlue'#14'Legend.Visible'#9#17'Title.Brush.C'
|
||||
+'olor'#7#9'clBtnFace'#16'Title.Font.Color'#7#6'clBlue'#18'Title.Text.Strings'
|
||||
+#1#6#7'TAChart'#0#5'Align'#7#8'alClient'#11'ParentColor'#8#0#11'TFuncSeries'
|
||||
+#17'Chart1FuncSeries1'#11'Extent.XMin'#5#0#248'(\'#143#194#245#200#1#192#11
|
||||
+'Extent.YMin'#5#0#0#0#0#0#0#0#128#255#191#11'Extent.XMax'#5#0#248'(\'#143#194
|
||||
+#245#200#1'@'#11'Extent.YMax'#5#0#0#0#0#0#0#0#128#255'?'#14'Extent.UseXMin'#9
|
||||
+#14'Extent.UseYMin'#9#14'Extent.UseXMax'#9#14'Extent.UseYMax'#9#11'OnCalcula'
|
||||
+'te'#7#26'Chart1FuncSeries1Calculate'#9'Pen.Color'#7#7'clOlive'#9'Pen.Width'
|
||||
+#2#2#4'Step'#2#4#5'Title'#6#6'Sin(x)'#0#0#5'TLine'#11'Chart1XAxis'#12'ShowIn'
|
||||
+'Legend'#8#8'Position'#5#0#0#0#0#0#0#0#0#0#0#11'SeriesColor'#7#7'clBlack'#0#0
|
||||
+#5'TLine'#11'Chart1YAxis'#12'ShowInLegend'#8#9'LineStyle'#7#10'lsVertical'#8
|
||||
+'Position'#5#0#0#0#0#0#0#0#0#0#0#11'SeriesColor'#7#7'clBlack'#0#0#10'TBarSer'
|
||||
+'ies'#16'Chart1BarSeries1'#5'Title'#6#6'Cos(x)'#14'BarBrush.Color'#7#12'clMo'
|
||||
+'neyGreen'#11'SeriesColor'#7#12'clMoneyGreen'#6'Source'#7#23'UserDefinedChar'
|
||||
+'tSource1'#0#0#16'TUserDrawnSeries'#22'Chart1UserDrawnSeries1'#6'OnDraw'#7#26
|
||||
+'Chart1UserDrawnSeries1Draw'#0#0#0#23'TUserDefinedChartSource'#23'UserDefine'
|
||||
+'dChartSource1'#18'OnGetChartDataItem'#7'''UserDefinedChartSource1GetChartDa'
|
||||
+'taItem'#12'PointsNumber'#2#14#4'left'#3#135#0#3'top'#2'r'#0#0#0
|
||||
]);
|
||||
|
@ -16,11 +16,12 @@ type
|
||||
Chart1: TChart;
|
||||
Chart1BarSeries1: TBarSeries;
|
||||
Chart1FuncSeries1: TFuncSeries;
|
||||
Chart1UserDrawnSeries1: TUserDrawnSeries;
|
||||
Chart1YAxis: TLine;
|
||||
Chart1XAxis: TLine;
|
||||
UserDefinedChartSource1: TUserDefinedChartSource;
|
||||
procedure Chart1FuncSeries1Calculate(const AX: Double; out AY: Double);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure Chart1UserDrawnSeries1Draw(ACanvas: TCanvas; const ARect: TRect);
|
||||
procedure UserDefinedChartSource1GetChartDataItem(
|
||||
ASource: TUserDefinedChartSource; AIndex: Integer;
|
||||
var AItem: TChartDataItem);
|
||||
@ -31,6 +32,9 @@ var
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
TAChartUtils;
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
procedure TForm1.Chart1FuncSeries1Calculate(const AX: Double; out AY: Double);
|
||||
@ -38,11 +42,20 @@ begin
|
||||
AY := Sin(AX);
|
||||
end;
|
||||
|
||||
procedure TForm1.FormCreate(Sender: TObject);
|
||||
procedure TForm1.Chart1UserDrawnSeries1Draw(
|
||||
ACanvas: TCanvas; const ARect: TRect);
|
||||
var
|
||||
a: TDoublePoint = (X: -1; Y: -1);
|
||||
b: TDoublePoint = (X: 1; Y: 1);
|
||||
r: TRect;
|
||||
begin
|
||||
Chart1FuncSeries1.OnCalculate := @Chart1FuncSeries1Calculate;
|
||||
UserDefinedChartSource1.OnGetChartDataItem :=
|
||||
@UserDefinedChartSource1GetChartDataItem;
|
||||
r.TopLeft := Chart1.GraphToImage(a);
|
||||
r.BottomRight := Chart1.GraphToImage(b);
|
||||
ACanvas.Pen.Mode := pmCopy;
|
||||
ACanvas.Pen.Color := clRed;
|
||||
ACanvas.Pen.Style := psDash;
|
||||
ACanvas.Brush.Style := bsClear;
|
||||
ACanvas.Ellipse(r);
|
||||
end;
|
||||
|
||||
procedure TForm1.UserDefinedChartSource1GetChartDataItem(
|
||||
|
Loading…
Reference in New Issue
Block a user