mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 18:39:52 +02:00
TAChart: Add demo for SortedChartSource. Based on code by Marcin Wiazowski (issue #35356). Some cosmetic changes in the chartsourcedemo.
git-svn-id: trunk@61253 -
This commit is contained in:
parent
3992921b51
commit
bab9f23e1d
@ -1,15 +1,15 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<CONFIG>
|
<CONFIG>
|
||||||
<ProjectOptions>
|
<ProjectOptions>
|
||||||
<Version Value="11"/>
|
<Version Value="12"/>
|
||||||
<PathDelim Value="\"/>
|
<PathDelim Value="\"/>
|
||||||
<General>
|
<General>
|
||||||
<Flags>
|
<Flags>
|
||||||
<SaveClosedFiles Value="False"/>
|
<SaveClosedFiles Value="False"/>
|
||||||
<LRSInOutputDirectory Value="False"/>
|
<LRSInOutputDirectory Value="False"/>
|
||||||
|
<CompatibilityMode Value="True"/>
|
||||||
</Flags>
|
</Flags>
|
||||||
<SessionStorage Value="InProjectDir"/>
|
<SessionStorage Value="InProjectDir"/>
|
||||||
<MainUnit Value="0"/>
|
|
||||||
<Scaled Value="True"/>
|
<Scaled Value="True"/>
|
||||||
<ResourceType Value="res"/>
|
<ResourceType Value="res"/>
|
||||||
<UseXPManifest Value="True"/>
|
<UseXPManifest Value="True"/>
|
||||||
@ -21,11 +21,14 @@
|
|||||||
<Version Value="2"/>
|
<Version Value="2"/>
|
||||||
</PublishOptions>
|
</PublishOptions>
|
||||||
<RunParams>
|
<RunParams>
|
||||||
|
<local>
|
||||||
|
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
|
||||||
|
</local>
|
||||||
<FormatVersion Value="2"/>
|
<FormatVersion Value="2"/>
|
||||||
<Modes Count="1">
|
<Modes Count="1">
|
||||||
<Mode0 Name="default">
|
<Mode0 Name="default">
|
||||||
<local>
|
<local>
|
||||||
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
|
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
|
||||||
</local>
|
</local>
|
||||||
</Mode0>
|
</Mode0>
|
||||||
</Modes>
|
</Modes>
|
||||||
|
@ -8,33 +8,24 @@ object Form1: TForm1
|
|||||||
ClientWidth = 637
|
ClientWidth = 637
|
||||||
OnCreate = FormCreate
|
OnCreate = FormCreate
|
||||||
LCLVersion = '2.1.0.0'
|
LCLVersion = '2.1.0.0'
|
||||||
object Splitter1: TSplitter
|
|
||||||
Left = 632
|
|
||||||
Height = 438
|
|
||||||
Top = 0
|
|
||||||
Width = 5
|
|
||||||
Align = alRight
|
|
||||||
Beveled = True
|
|
||||||
ResizeAnchor = akRight
|
|
||||||
end
|
|
||||||
object PageControl1: TPageControl
|
object PageControl1: TPageControl
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 438
|
Height = 438
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 632
|
Width = 637
|
||||||
ActivePage = tsBasic
|
ActivePage = tsBasic
|
||||||
Align = alClient
|
Align = alClient
|
||||||
TabIndex = 0
|
TabIndex = 0
|
||||||
TabOrder = 1
|
TabOrder = 0
|
||||||
object tsBasic: TTabSheet
|
object tsBasic: TTabSheet
|
||||||
Caption = 'Basic'
|
Caption = 'Basic'
|
||||||
ClientHeight = 410
|
ClientHeight = 410
|
||||||
ClientWidth = 624
|
ClientWidth = 629
|
||||||
object Memo1: TMemo
|
object Memo1: TMemo
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 34
|
Height = 34
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 624
|
Width = 629
|
||||||
Align = alTop
|
Align = alTop
|
||||||
Lines.Strings = (
|
Lines.Strings = (
|
||||||
'Modify sources at design-time.'
|
'Modify sources at design-time.'
|
||||||
@ -68,6 +59,7 @@ object Form1: TForm1
|
|||||||
'TAChart'
|
'TAChart'
|
||||||
)
|
)
|
||||||
Align = alClient
|
Align = alClient
|
||||||
|
Color = clWindow
|
||||||
object Chart2LineSeries1: TLineSeries
|
object Chart2LineSeries1: TLineSeries
|
||||||
LinePen.Color = clRed
|
LinePen.Color = clRed
|
||||||
Pointer.Brush.Color = clRed
|
Pointer.Brush.Color = clRed
|
||||||
@ -82,7 +74,7 @@ object Form1: TForm1
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
object Chart1: TChart
|
object Chart1: TChart
|
||||||
Left = 333
|
Left = 338
|
||||||
Height = 376
|
Height = 376
|
||||||
Top = 34
|
Top = 34
|
||||||
Width = 291
|
Width = 291
|
||||||
@ -107,6 +99,7 @@ object Form1: TForm1
|
|||||||
'TAChart'
|
'TAChart'
|
||||||
)
|
)
|
||||||
Align = alRight
|
Align = alRight
|
||||||
|
Color = clWindow
|
||||||
object Chart1BarSeries1: TBarSeries
|
object Chart1BarSeries1: TBarSeries
|
||||||
BarBrush.Color = clRed
|
BarBrush.Color = clRed
|
||||||
Source = RandomChartSource1
|
Source = RandomChartSource1
|
||||||
@ -120,16 +113,24 @@ object Form1: TForm1
|
|||||||
Source = ListChartSource1
|
Source = ListChartSource1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
object Splitter1: TSplitter
|
||||||
|
Left = 333
|
||||||
|
Height = 376
|
||||||
|
Top = 34
|
||||||
|
Width = 5
|
||||||
|
Align = alRight
|
||||||
|
ResizeAnchor = akRight
|
||||||
|
end
|
||||||
end
|
end
|
||||||
object tsStatistics: TTabSheet
|
object tsStatistics: TTabSheet
|
||||||
Caption = 'Statistics'
|
Caption = 'Statistics'
|
||||||
ClientHeight = 410
|
ClientHeight = 410
|
||||||
ClientWidth = 624
|
ClientWidth = 629
|
||||||
object chCalc: TChart
|
object chCalc: TChart
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 369
|
Height = 369
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 624
|
Width = 629
|
||||||
AxisList = <
|
AxisList = <
|
||||||
item
|
item
|
||||||
Marks.LabelBrush.Style = bsClear
|
Marks.LabelBrush.Style = bsClear
|
||||||
@ -156,6 +157,7 @@ object Form1: TForm1
|
|||||||
'TAChart'
|
'TAChart'
|
||||||
)
|
)
|
||||||
Align = alClient
|
Align = alClient
|
||||||
|
Color = clWindow
|
||||||
object chCalcLineSeries1: TLineSeries
|
object chCalcLineSeries1: TLineSeries
|
||||||
Title = 'Data'
|
Title = 'Data'
|
||||||
LineType = ltNone
|
LineType = ltNone
|
||||||
@ -181,11 +183,11 @@ object Form1: TForm1
|
|||||||
Left = 0
|
Left = 0
|
||||||
Height = 41
|
Height = 41
|
||||||
Top = 369
|
Top = 369
|
||||||
Width = 624
|
Width = 629
|
||||||
Align = alBottom
|
Align = alBottom
|
||||||
AutoSize = True
|
AutoSize = True
|
||||||
ClientHeight = 41
|
ClientHeight = 41
|
||||||
ClientWidth = 624
|
ClientWidth = 629
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
object cbCumulative: TCheckBox
|
object cbCumulative: TCheckBox
|
||||||
AnchorSideLeft.Control = Panel2
|
AnchorSideLeft.Control = Panel2
|
||||||
@ -231,12 +233,12 @@ object Form1: TForm1
|
|||||||
object tsDerivative: TTabSheet
|
object tsDerivative: TTabSheet
|
||||||
Caption = 'Derivative'
|
Caption = 'Derivative'
|
||||||
ClientHeight = 410
|
ClientHeight = 410
|
||||||
ClientWidth = 624
|
ClientWidth = 629
|
||||||
object chDerivative: TChart
|
object chDerivative: TChart
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 317
|
Height = 317
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 624
|
Width = 629
|
||||||
AxisList = <
|
AxisList = <
|
||||||
item
|
item
|
||||||
Grid.Color = clSilver
|
Grid.Color = clSilver
|
||||||
@ -268,6 +270,7 @@ object Form1: TForm1
|
|||||||
'TAChart'
|
'TAChart'
|
||||||
)
|
)
|
||||||
Align = alClient
|
Align = alClient
|
||||||
|
Color = clWindow
|
||||||
DoubleBuffered = True
|
DoubleBuffered = True
|
||||||
object chDerivativeLineOrig: TLineSeries
|
object chDerivativeLineOrig: TLineSeries
|
||||||
Title = 'y'
|
Title = 'y'
|
||||||
@ -280,12 +283,14 @@ object Form1: TForm1
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
object rgDataShape: TRadioGroup
|
object rgDataShape: TRadioGroup
|
||||||
Left = 0
|
Left = 6
|
||||||
Height = 54
|
Height = 54
|
||||||
Top = 317
|
Top = 317
|
||||||
Width = 624
|
Width = 617
|
||||||
Align = alBottom
|
Align = alBottom
|
||||||
AutoFill = True
|
AutoFill = True
|
||||||
|
BorderSpacing.Left = 6
|
||||||
|
BorderSpacing.Right = 6
|
||||||
Caption = 'Functions'
|
Caption = 'Functions'
|
||||||
ChildSizing.LeftRightSpacing = 6
|
ChildSizing.LeftRightSpacing = 6
|
||||||
ChildSizing.TopBottomSpacing = 6
|
ChildSizing.TopBottomSpacing = 6
|
||||||
@ -296,7 +301,7 @@ object Form1: TForm1
|
|||||||
ChildSizing.Layout = cclLeftToRightThenTopToBottom
|
ChildSizing.Layout = cclLeftToRightThenTopToBottom
|
||||||
ChildSizing.ControlsPerLine = 7
|
ChildSizing.ControlsPerLine = 7
|
||||||
ClientHeight = 34
|
ClientHeight = 34
|
||||||
ClientWidth = 620
|
ClientWidth = 613
|
||||||
Columns = 7
|
Columns = 7
|
||||||
ItemIndex = 0
|
ItemIndex = 0
|
||||||
Items.Strings = (
|
Items.Strings = (
|
||||||
@ -316,12 +321,12 @@ object Form1: TForm1
|
|||||||
Left = 0
|
Left = 0
|
||||||
Height = 39
|
Height = 39
|
||||||
Top = 371
|
Top = 371
|
||||||
Width = 624
|
Width = 629
|
||||||
Align = alBottom
|
Align = alBottom
|
||||||
AutoSize = True
|
AutoSize = True
|
||||||
BevelOuter = bvNone
|
BevelOuter = bvNone
|
||||||
ClientHeight = 39
|
ClientHeight = 39
|
||||||
ClientWidth = 624
|
ClientWidth = 629
|
||||||
TabOrder = 2
|
TabOrder = 2
|
||||||
object lblAccumulationRange: TLabel
|
object lblAccumulationRange: TLabel
|
||||||
AnchorSideLeft.Control = Panel1
|
AnchorSideLeft.Control = Panel1
|
||||||
@ -389,6 +394,97 @@ object Form1: TForm1
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
object tsSorted: TTabSheet
|
||||||
|
Caption = 'Sorted'
|
||||||
|
ClientHeight = 410
|
||||||
|
ClientWidth = 629
|
||||||
|
object btnSort: TButton
|
||||||
|
AnchorSideLeft.Control = tsSorted
|
||||||
|
AnchorSideTop.Control = tsSorted
|
||||||
|
Left = 8
|
||||||
|
Height = 25
|
||||||
|
Top = 8
|
||||||
|
Width = 230
|
||||||
|
AutoSize = True
|
||||||
|
BorderSpacing.Left = 8
|
||||||
|
BorderSpacing.Top = 8
|
||||||
|
Caption = 'Sort/unsort data by number of visitors!'
|
||||||
|
OnClick = btnSortClick
|
||||||
|
TabOrder = 0
|
||||||
|
end
|
||||||
|
object BubbleChart: TChart
|
||||||
|
AnchorSideLeft.Control = tsSorted
|
||||||
|
AnchorSideTop.Control = btnSort
|
||||||
|
AnchorSideTop.Side = asrBottom
|
||||||
|
AnchorSideRight.Control = tsSorted
|
||||||
|
AnchorSideRight.Side = asrBottom
|
||||||
|
AnchorSideBottom.Control = tsSorted
|
||||||
|
AnchorSideBottom.Side = asrBottom
|
||||||
|
Left = 8
|
||||||
|
Height = 361
|
||||||
|
Top = 41
|
||||||
|
Width = 613
|
||||||
|
AxisList = <
|
||||||
|
item
|
||||||
|
Visible = False
|
||||||
|
Marks.LabelBrush.Style = bsClear
|
||||||
|
Minors = <>
|
||||||
|
Title.LabelFont.Orientation = 900
|
||||||
|
Title.LabelBrush.Style = bsClear
|
||||||
|
end
|
||||||
|
item
|
||||||
|
Alignment = calBottom
|
||||||
|
Marks.Format = '%4:.9g'
|
||||||
|
Marks.LabelBrush.Style = bsClear
|
||||||
|
Marks.Source = SortedChartSource
|
||||||
|
Marks.Style = smsXValue
|
||||||
|
Minors = <>
|
||||||
|
Title.LabelBrush.Style = bsClear
|
||||||
|
end>
|
||||||
|
Foot.Brush.Color = clBtnFace
|
||||||
|
Foot.Font.Color = clBlue
|
||||||
|
Margins.Left = 20
|
||||||
|
Margins.Right = 40
|
||||||
|
Title.Brush.Color = clBtnFace
|
||||||
|
Title.Brush.Style = bsClear
|
||||||
|
Title.Font.Color = clBlue
|
||||||
|
Title.Text.Strings = (
|
||||||
|
'Locations of World Exposition X, and numbers of visitors (given by bubble size)'
|
||||||
|
)
|
||||||
|
Title.Visible = True
|
||||||
|
OnAfterPaint = BubbleChartAfterPaint
|
||||||
|
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||||
|
BorderSpacing.Around = 8
|
||||||
|
Color = clWindow
|
||||||
|
object BubbleSeries: TBubbleSeries
|
||||||
|
AxisIndexX = 1
|
||||||
|
AxisIndexY = 0
|
||||||
|
BubbleRadiusUnits = bruY
|
||||||
|
MarkPositions = lmpPositive
|
||||||
|
Marks.Attachment = maCenter
|
||||||
|
Marks.Distance = 0
|
||||||
|
Marks.LabelFont.Orientation = 900
|
||||||
|
Marks.Format = '%2:s'
|
||||||
|
Marks.LabelBrush.Color = clWhite
|
||||||
|
Marks.Style = smsLabel
|
||||||
|
OverrideColor = [bocBrush]
|
||||||
|
Source = SortedChartSource
|
||||||
|
end
|
||||||
|
end
|
||||||
|
object lblSortInfo: TLabel
|
||||||
|
AnchorSideLeft.Control = btnSort
|
||||||
|
AnchorSideLeft.Side = asrBottom
|
||||||
|
AnchorSideTop.Control = btnSort
|
||||||
|
AnchorSideTop.Side = asrCenter
|
||||||
|
Left = 246
|
||||||
|
Height = 15
|
||||||
|
Top = 13
|
||||||
|
Width = 55
|
||||||
|
BorderSpacing.Left = 8
|
||||||
|
Caption = 'lblSortInfo'
|
||||||
|
ParentColor = False
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
object RandomChartSource1: TRandomChartSource
|
object RandomChartSource1: TRandomChartSource
|
||||||
PointsNumber = 8
|
PointsNumber = 8
|
||||||
@ -397,8 +493,8 @@ object Form1: TForm1
|
|||||||
XMin = -5
|
XMin = -5
|
||||||
YMax = 10
|
YMax = 10
|
||||||
YMin = 0
|
YMin = 0
|
||||||
left = 240
|
left = 88
|
||||||
top = 204
|
top = 112
|
||||||
end
|
end
|
||||||
object ListChartSource1: TListChartSource
|
object ListChartSource1: TListChartSource
|
||||||
DataPoints.Strings = (
|
DataPoints.Strings = (
|
||||||
@ -408,22 +504,22 @@ object Form1: TForm1
|
|||||||
'0|1|?|'
|
'0|1|?|'
|
||||||
'3|2|?|'
|
'3|2|?|'
|
||||||
)
|
)
|
||||||
left = 240
|
left = 88
|
||||||
top = 260
|
top = 168
|
||||||
end
|
end
|
||||||
object ccsSum: TCalculatedChartSource
|
object ccsSum: TCalculatedChartSource
|
||||||
AccumulationMethod = camSum
|
AccumulationMethod = camSum
|
||||||
AccumulationRange = 0
|
AccumulationRange = 0
|
||||||
Origin = RandomChartSource2
|
Origin = RandomChartSource2
|
||||||
left = 504
|
left = 240
|
||||||
top = 112
|
top = 168
|
||||||
end
|
end
|
||||||
object ccsAvg: TCalculatedChartSource
|
object ccsAvg: TCalculatedChartSource
|
||||||
AccumulationMethod = camAverage
|
AccumulationMethod = camAverage
|
||||||
AccumulationRange = 5
|
AccumulationRange = 5
|
||||||
Origin = RandomChartSource2
|
Origin = RandomChartSource2
|
||||||
left = 504
|
left = 240
|
||||||
top = 168
|
top = 224
|
||||||
end
|
end
|
||||||
object RandomChartSource2: TRandomChartSource
|
object RandomChartSource2: TRandomChartSource
|
||||||
PointsNumber = 25
|
PointsNumber = 25
|
||||||
@ -432,17 +528,31 @@ object Form1: TForm1
|
|||||||
XMin = -10
|
XMin = -10
|
||||||
YMax = 8
|
YMax = 8
|
||||||
YMin = 1
|
YMin = 1
|
||||||
left = 504
|
left = 240
|
||||||
top = 268
|
top = 112
|
||||||
end
|
end
|
||||||
object lcsDerivative: TListChartSource
|
object lcsDerivative: TListChartSource
|
||||||
left = 156
|
left = 376
|
||||||
top = 84
|
top = 112
|
||||||
end
|
end
|
||||||
object ccsDerivative: TCalculatedChartSource
|
object ccsDerivative: TCalculatedChartSource
|
||||||
AccumulationMethod = camDerivative
|
AccumulationMethod = camDerivative
|
||||||
Origin = lcsDerivative
|
Origin = lcsDerivative
|
||||||
left = 156
|
left = 376
|
||||||
top = 140
|
top = 168
|
||||||
|
end
|
||||||
|
object UserDefinedChartSource: TUserDefinedChartSource
|
||||||
|
OnGetChartDataItem = UserDefinedChartSourceGetChartDataItem
|
||||||
|
YCount = 2
|
||||||
|
left = 528
|
||||||
|
top = 112
|
||||||
|
end
|
||||||
|
object SortedChartSource: TSortedChartSource
|
||||||
|
Origin = UserDefinedChartSource
|
||||||
|
SortBy = sbY
|
||||||
|
SortDir = sdDescending
|
||||||
|
SortIndex = 1
|
||||||
|
left = 528
|
||||||
|
top = 168
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -5,14 +5,22 @@ unit Main;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
ComCtrls, ExtCtrls, Spin, StdCtrls, Forms, TAGraph, TASeries, TASources,
|
Classes, StdCtrls, ComCtrls, ExtCtrls, Spin, Forms,
|
||||||
Classes;
|
TAGraph, TASeries, TACustomSource, TASources, TAMultiSeries, TAChartUtils;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
TDataForSorting = record
|
||||||
|
Year: Integer;
|
||||||
|
CityName: String;
|
||||||
|
Visitors: Integer;
|
||||||
|
Color: TChartColor;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TForm1 }
|
{ TForm1 }
|
||||||
|
|
||||||
TForm1 = class(TForm)
|
TForm1 = class(TForm)
|
||||||
|
btnSort: TButton;
|
||||||
|
BubbleSeries: TBubbleSeries;
|
||||||
cbAccDirDerivative: TComboBox;
|
cbAccDirDerivative: TComboBox;
|
||||||
ccsDerivative: TCalculatedChartSource;
|
ccsDerivative: TCalculatedChartSource;
|
||||||
cbCumulative: TCheckBox;
|
cbCumulative: TCheckBox;
|
||||||
@ -21,6 +29,7 @@ type
|
|||||||
Chart1: TChart;
|
Chart1: TChart;
|
||||||
Chart1BarSeries1: TBarSeries;
|
Chart1BarSeries1: TBarSeries;
|
||||||
Chart1LineSeries1: TLineSeries;
|
Chart1LineSeries1: TLineSeries;
|
||||||
|
BubbleChart: TChart;
|
||||||
chDerivativeLineOrig: TLineSeries;
|
chDerivativeLineOrig: TLineSeries;
|
||||||
chDerivativeLineDeriv: TLineSeries;
|
chDerivativeLineDeriv: TLineSeries;
|
||||||
Chart1LineSeries4: TLineSeries;
|
Chart1LineSeries4: TLineSeries;
|
||||||
@ -35,6 +44,7 @@ type
|
|||||||
chCalcLineSeriesSum: TLineSeries;
|
chCalcLineSeriesSum: TLineSeries;
|
||||||
cbAccDirStatistics: TComboBox;
|
cbAccDirStatistics: TComboBox;
|
||||||
cbSmooth: TCheckBox;
|
cbSmooth: TCheckBox;
|
||||||
|
lblSortInfo: TLabel;
|
||||||
seAccumulationRange: TSpinEdit;
|
seAccumulationRange: TSpinEdit;
|
||||||
lblAccumulationRange: TLabel;
|
lblAccumulationRange: TLabel;
|
||||||
ListChartSource1: TListChartSource;
|
ListChartSource1: TListChartSource;
|
||||||
@ -46,18 +56,29 @@ type
|
|||||||
rgDataShape: TRadioGroup;
|
rgDataShape: TRadioGroup;
|
||||||
RandomChartSource1: TRandomChartSource;
|
RandomChartSource1: TRandomChartSource;
|
||||||
RandomChartSource2: TRandomChartSource;
|
RandomChartSource2: TRandomChartSource;
|
||||||
|
SortedChartSource: TSortedChartSource;
|
||||||
Splitter1: TSplitter;
|
Splitter1: TSplitter;
|
||||||
|
tsSorted: TTabSheet;
|
||||||
tsDerivative: TTabSheet;
|
tsDerivative: TTabSheet;
|
||||||
tsStatistics: TTabSheet;
|
tsStatistics: TTabSheet;
|
||||||
tsBasic: TTabSheet;
|
tsBasic: TTabSheet;
|
||||||
|
UserDefinedChartSource: TUserDefinedChartSource;
|
||||||
|
procedure btnSortClick(Sender: TObject);
|
||||||
|
procedure BubbleChartAfterPaint(ASender: TChart);
|
||||||
procedure cbAccDirDerivativeChange(Sender: TObject);
|
procedure cbAccDirDerivativeChange(Sender: TObject);
|
||||||
procedure cbAccDirStatisticsChange(Sender: TObject);
|
procedure cbAccDirStatisticsChange(Sender: TObject);
|
||||||
procedure cbCumulativeChange(Sender: TObject);
|
procedure cbCumulativeChange(Sender: TObject);
|
||||||
procedure cbSmoothChange(Sender: TObject);
|
procedure cbSmoothChange(Sender: TObject);
|
||||||
procedure CreateData;
|
procedure CreateDataForDerivative;
|
||||||
|
procedure CreateDataForSorting;
|
||||||
procedure seAccumulationRangeChange(Sender: TObject);
|
procedure seAccumulationRangeChange(Sender: TObject);
|
||||||
procedure FormCreate(Sender: TObject);
|
procedure FormCreate(Sender: TObject);
|
||||||
procedure rgDataShapeClick(Sender: TObject);
|
procedure rgDataShapeClick(Sender: TObject);
|
||||||
|
procedure UserDefinedChartSourceGetChartDataItem(
|
||||||
|
ASource: TUserDefinedChartSource; AIndex: Integer;
|
||||||
|
var AItem: TChartDataItem);
|
||||||
|
private
|
||||||
|
FDataForSorting: array of TDataForSorting;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
@ -78,6 +99,19 @@ begin
|
|||||||
TChartAccumulationDirection(cbAccDirDerivative.ItemIndex);
|
TChartAccumulationDirection(cbAccDirDerivative.ItemIndex);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.btnSortClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
SortedChartSource.Sorted := not SortedChartSource.Sorted;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.BubbleChartAfterPaint(ASender: TChart);
|
||||||
|
begin
|
||||||
|
if SortedChartSource.IsSorted then
|
||||||
|
lblSortInfo.Caption := 'Sorted by radius (descending)'
|
||||||
|
else
|
||||||
|
lblSortInfo.Caption := 'Not sorted';
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TForm1.cbAccDirStatisticsChange(Sender: TObject);
|
procedure TForm1.cbAccDirStatisticsChange(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
ccsAvg.AccumulationDirection :=
|
ccsAvg.AccumulationDirection :=
|
||||||
@ -98,7 +132,7 @@ begin
|
|||||||
ccsDerivative.AccumulationMethod := camDerivative;
|
ccsDerivative.AccumulationMethod := camDerivative;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TForm1.CreateData;
|
procedure TForm1.CreateDataForDerivative;
|
||||||
const
|
const
|
||||||
N = 100;
|
N = 100;
|
||||||
MIN_X = -10;
|
MIN_X = -10;
|
||||||
@ -128,15 +162,58 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.CreateDataForSorting;
|
||||||
|
|
||||||
|
procedure AddCity(AYear: Integer; const ACityName: string;
|
||||||
|
ANumberOfVisitors: Integer; AColor: TChartColor);
|
||||||
|
begin
|
||||||
|
SetLength(FDataForSorting, Length(FDataForSorting) + 1);
|
||||||
|
with FDataForSorting[High(FDataForSorting)] do begin
|
||||||
|
Year := AYear;
|
||||||
|
CityName := ACityName;
|
||||||
|
Visitors := ANumberOfVisitors;
|
||||||
|
Color := AColor;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
SetLength(FDataForSorting, 0);
|
||||||
|
AddCity(1967, 'City A', 155000, $00FFFF); // yellow
|
||||||
|
AddCity(1968, 'City B', 30000, $FF0000); // blue
|
||||||
|
AddCity(1969, 'City C', 450000, $FF00FF); // fuchsia
|
||||||
|
AddCity(1970, 'City D', 50000, $FFFF00); // aqua
|
||||||
|
AddCity(1971, 'City E', 80000, $00FF00); // lime
|
||||||
|
AddCity(1972, 'City F', 615000, $0000FF); // red
|
||||||
|
UserDefinedChartSource.PointsNumber := Length(FDataForSorting);
|
||||||
|
|
||||||
|
{ These settings are made in the Object Inspector for the SortedChartSource:
|
||||||
|
- Origin = UserDefinedChartSource
|
||||||
|
- SortBy = sbY
|
||||||
|
- SortIndex = 1 // --> sort by radius
|
||||||
|
- SortDir = sdDescending // --> draw large bubbles first
|
||||||
|
}
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TForm1.FormCreate(Sender: TObject);
|
procedure TForm1.FormCreate(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
Randomize;
|
Randomize;
|
||||||
CreateData;
|
CreateDataForDerivative;
|
||||||
|
CreateDataForSorting;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TForm1.rgDataShapeClick(Sender: TObject);
|
procedure TForm1.rgDataShapeClick(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
CreateData;
|
CreateDataForDerivative;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.UserDefinedChartSourceGetChartDataItem(
|
||||||
|
ASource: TUserDefinedChartSource; AIndex: Integer; var AItem: TChartDataItem);
|
||||||
|
begin
|
||||||
|
AItem.X := FDataForSorting[AIndex].Year;
|
||||||
|
AItem.Y := 0;
|
||||||
|
AItem.YList[0] := Sqrt(FDataForSorting[AIndex].Visitors/100000 / PI);
|
||||||
|
AItem.Text := FDataForSorting[AIndex].CityName;
|
||||||
|
AItem.Color := FDataForSorting[AIndex].Color;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TForm1.seAccumulationRangeChange(Sender: TObject);
|
procedure TForm1.seAccumulationRangeChange(Sender: TObject);
|
||||||
|
Loading…
Reference in New Issue
Block a user