mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-31 11:00:32 +02:00
TAChart: Use TUserDefinedChartSource in function demo
git-svn-id: trunk@20173 -
This commit is contained in:
parent
1388b69516
commit
326dadbb51
@ -15,13 +15,10 @@ object Form1: TForm1
|
||||
Top = 0
|
||||
Width = 461
|
||||
BottomAxis.Grid.Style = psDot
|
||||
BottomAxis.Grid.Visible = True
|
||||
ExpandPercentage = 10
|
||||
Foot.Brush.Color = clBtnFace
|
||||
Foot.Font.Color = clBlue
|
||||
Frame.Visible = True
|
||||
LeftAxis.Grid.Style = psDot
|
||||
LeftAxis.Grid.Visible = True
|
||||
LeftAxis.Title.Angle = 90
|
||||
Legend.Visible = True
|
||||
Title.Brush.Color = clBtnFace
|
||||
@ -56,5 +53,16 @@ object Form1: TForm1
|
||||
Position = 0
|
||||
SeriesColor = clBlack
|
||||
end
|
||||
object Chart1BarSeries1: TBarSeries
|
||||
Title = 'Cos(x)'
|
||||
BarBrush.Color = clMoneyGreen
|
||||
SeriesColor = clMoneyGreen
|
||||
Source = UserDefinedChartSource1
|
||||
end
|
||||
end
|
||||
object UserDefinedChartSource1: TUserDefinedChartSource
|
||||
PointsNumber = 14
|
||||
left = 135
|
||||
top = 114
|
||||
end
|
||||
end
|
||||
|
@ -5,19 +5,22 @@ LazarusResources.Add('TForm1','FORMDATA',[
|
||||
+'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'#23'BottomAxis.'
|
||||
+'Grid.Visible'#9#16'ExpandPercentage'#2#10#16'Foot.Brush.Color'#7#9'clBtnFac'
|
||||
+'e'#15'Foot.Font.Color'#7#6'clBlue'#13'Frame.Visible'#9#19'LeftAxis.Grid.Sty'
|
||||
+'le'#7#5'psDot'#21'LeftAxis.Grid.Visible'#9#20'LeftAxis.Title.Angle'#2'Z'#14
|
||||
+'Legend.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'Po'
|
||||
+'sition'#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#0#0
|
||||
+'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
|
||||
]);
|
||||
|
@ -6,7 +6,7 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
|
||||
TAGraph, TASeries;
|
||||
TAGraph, TASeries, TASources;
|
||||
|
||||
type
|
||||
|
||||
@ -14,11 +14,16 @@ type
|
||||
|
||||
TForm1 = class(TForm)
|
||||
Chart1: TChart;
|
||||
Chart1BarSeries1: TBarSeries;
|
||||
Chart1FuncSeries1: TFuncSeries;
|
||||
Chart1YAxis: TLine;
|
||||
Chart1XAxis: TLine;
|
||||
UserDefinedChartSource1: TUserDefinedChartSource;
|
||||
procedure Chart1FuncSeries1Calculate(const AX: Double; out AY: Double);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure UserDefinedChartSource1GetChartDataItem(
|
||||
ASource: TUserDefinedChartSource; AIndex: Integer;
|
||||
var AItem: TChartDataItem);
|
||||
end;
|
||||
|
||||
var
|
||||
@ -36,6 +41,15 @@ end;
|
||||
procedure TForm1.FormCreate(Sender: TObject);
|
||||
begin
|
||||
Chart1FuncSeries1.OnCalculate := @Chart1FuncSeries1Calculate;
|
||||
UserDefinedChartSource1.OnGetChartDataItem :=
|
||||
@UserDefinedChartSource1GetChartDataItem;
|
||||
end;
|
||||
|
||||
procedure TForm1.UserDefinedChartSource1GetChartDataItem(
|
||||
ASource: TUserDefinedChartSource; AIndex: Integer; var AItem: TChartDataItem);
|
||||
begin
|
||||
AItem.X := AIndex - ASource.PointsNumber / 2;
|
||||
AItem.Y := Cos(AItem.X);
|
||||
end;
|
||||
|
||||
initialization
|
||||
|
Loading…
Reference in New Issue
Block a user