TAChart: Improve reticules.

- unify and simplify reticule drawing
  - allow vertical, horizontal or cross reticules
  - update demo

git-svn-id: trunk@19025 -
This commit is contained in:
ask 2009-03-18 16:24:07 +00:00
parent c3693ef736
commit 073e79c380
5 changed files with 178 additions and 234 deletions

View File

@ -9,18 +9,16 @@ object Form1: TForm1
Position = poScreenCenter
LCLVersion = '0.9.27'
object Chart1: TChart
Height = 400
Height = 392
Width = 585
Legend.Alignment = laRight
Legend.Font.Height = -11
Legend.Font.Name = 'MS Sans Serif'
Legend.Frame.Cosmetic = True
Title.Alignment = taCenter
Title.Brush.Color = clBtnFace
Title.Font.Color = clBlue
Title.Font.Height = -11
Title.Font.Name = 'MS Sans Serif'
Title.Frame.Cosmetic = True
Title.Text.Strings = (
'Centered Chart Title'
)
@ -30,12 +28,10 @@ object Form1: TForm1
Foot.Font.Height = -13
Foot.Font.Name = 'MS Sans Serif'
Foot.Font.Style = [fsBold]
Foot.Frame.Cosmetic = True
Foot.Text.Strings = (
'This a LeftAligned Footer'
)
LeftAxis.Grid.Color = clGray
LeftAxis.Grid.Cosmetic = True
LeftAxis.Grid.Style = psDot
LeftAxis.Grid.Visible = True
LeftAxis.Title.Angle = 90
@ -43,42 +39,34 @@ object Form1: TForm1
LeftAxis.Title.Font.Name = 'MS Sans Serif'
LeftAxis.Visible = True
BottomAxis.Grid.Color = clGray
BottomAxis.Grid.Cosmetic = True
BottomAxis.Grid.Style = psDot
BottomAxis.Grid.Visible = True
BottomAxis.Title.Font.Height = -11
BottomAxis.Title.Font.Name = 'MS Sans Serif'
BottomAxis.Visible = True
Frame.Cosmetic = True
Frame.Visible = True
BackColor = clBtnFace
Align = alClient
Color = clBtnFace
ParentColor = False
object Chart1LineHor: TLine
Marks.Frame.Cosmetic = True
Marks.LinkPen.Cosmetic = True
ShowInLegend = False
Pen.Cosmetic = True
Pen.Style = psDot
SeriesColor = clBlack
end
object Chart1LineVert: TLine
Marks.Frame.Cosmetic = True
Marks.LinkPen.Cosmetic = True
ShowInLegend = False
LineStyle = lsVertical
Pen.Cosmetic = True
Pen.Style = psDot
SeriesColor = clBlack
end
end
object Panel1: TPanel
Height = 94
Top = 400
Height = 102
Top = 392
Width = 585
Align = alBottom
ClientHeight = 94
ClientHeight = 102
ClientWidth = 585
TabOrder = 0
object lblAdd: TLabel
@ -106,13 +94,21 @@ object Form1: TForm1
ParentColor = False
end
object lblMarkStyle: TLabel
Left = 152
Left = 48
Height = 14
Top = 68
Top = 80
Width = 78
Caption = 'Add with marks:'
ParentColor = False
end
object lblReticule: TLabel
Left = 360
Height = 14
Top = 80
Width = 43
Caption = 'Reticule:'
ParentColor = False
end
object btnAddPie: TButton
Left = 48
Height = 24
@ -283,28 +279,10 @@ object Form1: TForm1
OnChange = cbShowAxisTitlesChange
TabOrder = 16
end
object cbShowVertReticule: TCheckBox
Left = 384
Height = 17
Top = 72
Width = 76
Caption = 'Vert reticule'
OnChange = cbShowVertReticuleChange
TabOrder = 17
end
object cbShowReticule: TCheckBox
Left = 496
Height = 17
Top = 72
Width = 59
Caption = 'Reticule'
OnChange = cbShowReticuleChange
TabOrder = 18
end
object cbMarkStyle: TComboBox
Left = 240
Left = 132
Height = 21
Top = 68
Top = 76
Width = 136
ItemHeight = 13
ItemIndex = 5
@ -322,8 +300,26 @@ object Form1: TForm1
'smsXValue'
)
Style = csDropDownList
TabOrder = 19
TabOrder = 17
Text = 'smsLabelPercent'
end
object cbReticule: TComboBox
Left = 416
Height = 21
Top = 76
Width = 136
ItemHeight = 13
ItemIndex = 0
Items.Strings = (
'rmNone'
'rmVertical'
'rmHorizontal'
'rmCross'
)
OnChange = cbReticuleChange
Style = csDropDownList
TabOrder = 18
Text = 'rmNone'
end
end
end

View File

@ -4,89 +4,86 @@ LazarusResources.Add('TForm1','FORMDATA',[
'TPF0'#6'TForm1'#5'Form1'#4'Left'#3'U'#1#6'Height'#3#238#1#3'Top'#3#225#0#5'W'
+'idth'#3'I'#2#7'Caption'#6#5'Form1'#12'ClientHeight'#3#238#1#11'ClientWidth'
+#3'I'#2#8'Position'#7#14'poScreenCenter'#10'LCLVersion'#6#6'0.9.27'#0#6'TCha'
+'rt'#6'Chart1'#6'Height'#3#144#1#5'Width'#3'I'#2#16'Legend.Alignment'#7#7'la'
+'rt'#6'Chart1'#6'Height'#3#136#1#5'Width'#3'I'#2#16'Legend.Alignment'#7#7'la'
+'Right'#18'Legend.Font.Height'#2#245#16'Legend.Font.Name'#6#13'MS Sans Serif'
+#21'Legend.Frame.Cosmetic'#9#15'Title.Alignment'#7#8'taCenter'#17'Title.Brus'
+'h.Color'#7#9'clBtnFace'#16'Title.Font.Color'#7#6'clBlue'#17'Title.Font.Heig'
+'ht'#2#245#15'Title.Font.Name'#6#13'MS Sans Serif'#20'Title.Frame.Cosmetic'#9
+#18'Title.Text.Strings'#1#6#20'Centered Chart Title'#0#13'Title.Visible'#9#16
+'Foot.Brush.Color'#7#9'clBtnFace'#15'Foot.Font.Color'#7#5'clRed'#16'Foot.Fon'
+'t.Height'#2#243#14'Foot.Font.Name'#6#13'MS Sans Serif'#15'Foot.Font.Style'
+#11#6'fsBold'#0#19'Foot.Frame.Cosmetic'#9#17'Foot.Text.Strings'#1#6#25'This '
+'a LeftAligned Footer'#0#19'LeftAxis.Grid.Color'#7#6'clGray'#22'LeftAxis.Gri'
+'d.Cosmetic'#9#19'LeftAxis.Grid.Style'#7#5'psDot'#21'LeftAxis.Grid.Visible'#9
+#20'LeftAxis.Title.Angle'#2'Z'#26'LeftAxis.Title.Font.Height'#2#245#24'LeftA'
+'xis.Title.Font.Name'#6#13'MS Sans Serif'#16'LeftAxis.Visible'#9#21'BottomAx'
+'is.Grid.Color'#7#6'clGray'#24'BottomAxis.Grid.Cosmetic'#9#21'BottomAxis.Gri'
+'d.Style'#7#5'psDot'#23'BottomAxis.Grid.Visible'#9#28'BottomAxis.Title.Font.'
+'Height'#2#245#26'BottomAxis.Title.Font.Name'#6#13'MS Sans Serif'#18'BottomA'
+'xis.Visible'#9#14'Frame.Cosmetic'#9#13'Frame.Visible'#9#9'BackColor'#7#9'cl'
+'BtnFace'#5'Align'#7#8'alClient'#5'Color'#7#9'clBtnFace'#11'ParentColor'#8#0
+#5'TLine'#13'Chart1LineHor'#20'Marks.Frame.Cosmetic'#9#22'Marks.LinkPen.Cosm'
+'etic'#9#12'ShowInLegend'#8#12'Pen.Cosmetic'#9#9'Pen.Style'#7#5'psDot'#11'Se'
+'riesColor'#7#7'clBlack'#0#0#5'TLine'#14'Chart1LineVert'#20'Marks.Frame.Cosm'
+'etic'#9#22'Marks.LinkPen.Cosmetic'#9#12'ShowInLegend'#8#9'LineStyle'#7#10'l'
+'sVertical'#12'Pen.Cosmetic'#9#9'Pen.Style'#7#5'psDot'#11'SeriesColor'#7#7'c'
+'lBlack'#0#0#0#6'TPanel'#6'Panel1'#6'Height'#2'^'#3'Top'#3#144#1#5'Width'#3
+'I'#2#5'Align'#7#8'alBottom'#12'ClientHeight'#2'^'#11'ClientWidth'#3'I'#2#8
+'TabOrder'#2#0#0#6'TLabel'#6'lblAdd'#4'Left'#2#13#6'Height'#2#14#3'Top'#2#10
+#5'Width'#2#24#7'Caption'#6#4'Add:'#11'ParentColor'#8#0#0#6'TLabel'#8'lblCle'
+'ar'#4'Left'#2#13#6'Height'#2#14#3'Top'#2'('#5'Width'#2#30#7'Caption'#6#6'Cl'
+'ear:'#11'ParentColor'#8#0#0#6'TLabel'#11'lblAddCount'#4'Left'#3' '#1#6'Heig'
+'ht'#2#14#3'Top'#2#8#5'Width'#2':'#7'Caption'#6#12'Multiple add'#11'ParentCo'
+'lor'#8#0#0#6'TLabel'#12'lblMarkStyle'#4'Left'#3#152#0#6'Height'#2#14#3'Top'
+#2'D'#5'Width'#2'N'#7'Caption'#6#15'Add with marks:'#11'ParentColor'#8#0#0#7
+'TButton'#9'btnAddPie'#4'Left'#2'0'#6'Height'#2#24#3'Top'#2#8#5'Width'#2'4'
+#25'BorderSpacing.InnerBorder'#2#4#7'Caption'#6#3'Pie'#7'OnClick'#7#14'btnAd'
+'dPieClick'#8'TabOrder'#2#0#0#0#7'TButton'#10'btnAddLine'#4'Left'#3#216#0#6
+'Height'#2#24#3'Top'#2#8#5'Width'#2'4'#25'BorderSpacing.InnerBorder'#2#4#7'C'
+'aption'#6#4'Line'#7'OnClick'#7#15'btnAddLineClick'#8'TabOrder'#2#1#0#0#7'TB'
+'utton'#10'btnAddArea'#4'Left'#2'h'#6'Height'#2#24#3'Top'#2#8#5'Width'#2'4'
+#25'BorderSpacing.InnerBorder'#2#4#7'Caption'#6#4'Area'#7'OnClick'#7#15'btnA'
+'ddAreaClick'#8'TabOrder'#2#2#0#0#7'TButton'#9'btnAddBar'#4'Left'#3#160#0#6
+'Height'#2#24#3'Top'#2#8#5'Width'#2'4'#25'BorderSpacing.InnerBorder'#2#4#7'C'
+'aption'#6#3'Bar'#7'OnClick'#7#14'btnAddBarClick'#8'TabOrder'#2#3#0#0#9'TChe'
+'ckBox'#8'cbLegend'#4'Left'#3#128#1#6'Height'#2#17#3'Top'#2#8#5'Width'#2'8'#7
+'Caption'#6#6'Legend'#8'OnChange'#7#14'cbLegendChange'#8'TabOrder'#2#4#0#0#9
+'TCheckBox'#12'cbBottomAxis'#4'Left'#3#128#1#6'Height'#2#17#3'Top'#2#24#5'Wi'
+'dth'#2'K'#7'Caption'#6#11'Bottom Axis'#7'Checked'#9#8'OnChange'#7#18'cbBott'
+'omAxisChange'#5'State'#7#9'cbChecked'#8'TabOrder'#2#5#0#0#9'TCheckBox'#10'c'
+'bLeftAxis'#4'Left'#3#128#1#6'Height'#2#17#3'Top'#2'('#5'Width'#2'<'#7'Capti'
+'on'#6#9'Left Axis'#7'Checked'#9#8'OnChange'#7#16'cbLeftAxisChange'#5'State'
+#7#9'cbChecked'#8'TabOrder'#2#6#0#0#9'TCheckBox'#7'cbTitle'#4'Left'#3#240#1#6
+'Height'#2#17#3'Top'#2#8#5'Width'#2'('#7'Caption'#6#5'Title'#7'Checked'#9#8
+'OnChange'#7#13'cbTitleChange'#5'State'#7#9'cbChecked'#8'TabOrder'#2#7#0#0#9
+'TCheckBox'#8'cbFooter'#4'Left'#3#240#1#6'Height'#2#17#3'Top'#2#24#5'Width'#2
+'2'#7'Caption'#6#6'Footer'#8'OnChange'#7#14'cbFooterChange'#8'TabOrder'#2#8#0
+#0#9'TCheckBox'#10'cbInverted'#4'Left'#3#240#1#6'Height'#2#17#3'Top'#2'('#5
+'Width'#2';'#7'Caption'#6#8'Inverted'#8'OnChange'#7#16'cbInvertedChange'#8'T'
+'abOrder'#2#9#0#0#7'TButton'#11'btnClearBar'#4'Left'#3#160#0#6'Height'#2#24#3
+'Top'#2'&'#5'Width'#2'4'#25'BorderSpacing.InnerBorder'#2#4#7'Caption'#6#3'Ba'
+'r'#7'OnClick'#7#16'btnClearBarClick'#8'TabOrder'#2#10#0#0#7'TButton'#12'btn'
+'ClearArea'#4'Left'#2'h'#6'Height'#2#24#3'Top'#2'&'#5'Width'#2'4'#25'BorderS'
+'pacing.InnerBorder'#2#4#7'Caption'#6#4'Area'#7'OnClick'#7#17'btnClearAreaCl'
,'ick'#8'TabOrder'#2#11#0#0#7'TButton'#12'btnClearLine'#4'Left'#3#216#0#6'Hei'
+'ght'#2#24#3'Top'#2'&'#5'Width'#2'4'#25'BorderSpacing.InnerBorder'#2#4#7'Cap'
+'tion'#6#4'Line'#7'OnClick'#7#17'btnClearLineClick'#8'TabOrder'#2#12#0#0#7'T'
+'Button'#11'btnClearPie'#4'Left'#2'0'#6'Height'#2#24#3'Top'#2'&'#5'Width'#2
+'4'#25'BorderSpacing.InnerBorder'#2#4#7'Caption'#6#3'Pie'#7'OnClick'#7#16'bt'
+'nClearPieClick'#8'TabOrder'#2#13#0#0#9'TSpinEdit'#10'edAddCount'#4'Left'#3
+' '#1#6'Height'#2#21#3'Top'#2#24#5'Width'#2'Z'#8'MaxValue'#4'@B'#15#0#8'MinV'
+'alue'#2#1#8'TabOrder'#2#14#5'Value'#2#1#0#0#9'TCheckBox'#18'cbShowGridCheck'
+'Box'#4'Left'#3#128#1#6'Height'#2#17#3'Top'#2'8'#5'Width'#2'F'#7'Caption'#6
+#10'Show grid '#7'Checked'#9#8'OnChange'#7#24'cbShowGridCheckBoxChange'#5'St'
+'ate'#7#9'cbChecked'#8'TabOrder'#2#15#0#0#9'TCheckBox'#16'cbShowAxisTitles'#4
+'Left'#3#240#1#6'Height'#2#17#3'Top'#2'8'#5'Width'#2'?'#7'Caption'#6#11'Axis'
+' titles'#8'OnChange'#7#22'cbShowAxisTitlesChange'#8'TabOrder'#2#16#0#0#9'TC'
+'heckBox'#18'cbShowVertReticule'#4'Left'#3#128#1#6'Height'#2#17#3'Top'#2'H'#5
+'Width'#2'L'#7'Caption'#6#13'Vert reticule'#8'OnChange'#7#24'cbShowVertRetic'
+'uleChange'#8'TabOrder'#2#17#0#0#9'TCheckBox'#14'cbShowReticule'#4'Left'#3
+#240#1#6'Height'#2#17#3'Top'#2'H'#5'Width'#2';'#7'Caption'#6#8'Reticule'#8'O'
+'nChange'#7#20'cbShowReticuleChange'#8'TabOrder'#2#18#0#0#9'TComboBox'#11'cb'
+'MarkStyle'#4'Left'#3#240#0#6'Height'#2#21#3'Top'#2'D'#5'Width'#3#136#0#10'I'
+'temHeight'#2#13#9'ItemIndex'#2#5#13'Items.Strings'#1#6#9'smsCustom'#6#7'sms'
+'None'#6#8'smsValue'#6#10'smsPercent'#6#8'smsLabel'#6#15'smsLabelPercent'#6
+#13'smsLabelValue'#6#9'smsLegend'#6#15'smsPercentTotal'#6#20'smsLabelPercent'
+'Total'#6#9'smsXValue'#0#5'Style'#7#14'csDropDownList'#8'TabOrder'#2#19#4'Te'
+'xt'#6#15'smsLabelPercent'#0#0#0#0
+#15'Title.Alignment'#7#8'taCenter'#17'Title.Brush.Color'#7#9'clBtnFace'#16'T'
+'itle.Font.Color'#7#6'clBlue'#17'Title.Font.Height'#2#245#15'Title.Font.Name'
+#6#13'MS Sans Serif'#18'Title.Text.Strings'#1#6#20'Centered Chart Title'#0#13
+'Title.Visible'#9#16'Foot.Brush.Color'#7#9'clBtnFace'#15'Foot.Font.Color'#7#5
+'clRed'#16'Foot.Font.Height'#2#243#14'Foot.Font.Name'#6#13'MS Sans Serif'#15
+'Foot.Font.Style'#11#6'fsBold'#0#17'Foot.Text.Strings'#1#6#25'This a LeftAli'
+'gned Footer'#0#19'LeftAxis.Grid.Color'#7#6'clGray'#19'LeftAxis.Grid.Style'#7
+#5'psDot'#21'LeftAxis.Grid.Visible'#9#20'LeftAxis.Title.Angle'#2'Z'#26'LeftA'
+'xis.Title.Font.Height'#2#245#24'LeftAxis.Title.Font.Name'#6#13'MS Sans Seri'
+'f'#16'LeftAxis.Visible'#9#21'BottomAxis.Grid.Color'#7#6'clGray'#21'BottomAx'
+'is.Grid.Style'#7#5'psDot'#23'BottomAxis.Grid.Visible'#9#28'BottomAxis.Title'
+'.Font.Height'#2#245#26'BottomAxis.Title.Font.Name'#6#13'MS Sans Serif'#18'B'
+'ottomAxis.Visible'#9#13'Frame.Visible'#9#9'BackColor'#7#9'clBtnFace'#5'Alig'
+'n'#7#8'alClient'#5'Color'#7#9'clBtnFace'#11'ParentColor'#8#0#5'TLine'#13'Ch'
+'art1LineHor'#12'ShowInLegend'#8#9'Pen.Style'#7#5'psDot'#11'SeriesColor'#7#7
+'clBlack'#0#0#5'TLine'#14'Chart1LineVert'#12'ShowInLegend'#8#9'LineStyle'#7
+#10'lsVertical'#9'Pen.Style'#7#5'psDot'#11'SeriesColor'#7#7'clBlack'#0#0#0#6
+'TPanel'#6'Panel1'#6'Height'#2'f'#3'Top'#3#136#1#5'Width'#3'I'#2#5'Align'#7#8
+'alBottom'#12'ClientHeight'#2'f'#11'ClientWidth'#3'I'#2#8'TabOrder'#2#0#0#6
+'TLabel'#6'lblAdd'#4'Left'#2#13#6'Height'#2#14#3'Top'#2#10#5'Width'#2#24#7'C'
+'aption'#6#4'Add:'#11'ParentColor'#8#0#0#6'TLabel'#8'lblClear'#4'Left'#2#13#6
+'Height'#2#14#3'Top'#2'('#5'Width'#2#30#7'Caption'#6#6'Clear:'#11'ParentColo'
+'r'#8#0#0#6'TLabel'#11'lblAddCount'#4'Left'#3' '#1#6'Height'#2#14#3'Top'#2#8
+#5'Width'#2':'#7'Caption'#6#12'Multiple add'#11'ParentColor'#8#0#0#6'TLabel'
+#12'lblMarkStyle'#4'Left'#2'0'#6'Height'#2#14#3'Top'#2'P'#5'Width'#2'N'#7'Ca'
+'ption'#6#15'Add with marks:'#11'ParentColor'#8#0#0#6'TLabel'#11'lblReticule'
+#4'Left'#3'h'#1#6'Height'#2#14#3'Top'#2'P'#5'Width'#2'+'#7'Caption'#6#9'Reti'
+'cule:'#11'ParentColor'#8#0#0#7'TButton'#9'btnAddPie'#4'Left'#2'0'#6'Height'
+#2#24#3'Top'#2#8#5'Width'#2'4'#25'BorderSpacing.InnerBorder'#2#4#7'Caption'#6
+#3'Pie'#7'OnClick'#7#14'btnAddPieClick'#8'TabOrder'#2#0#0#0#7'TButton'#10'bt'
+'nAddLine'#4'Left'#3#216#0#6'Height'#2#24#3'Top'#2#8#5'Width'#2'4'#25'Border'
+'Spacing.InnerBorder'#2#4#7'Caption'#6#4'Line'#7'OnClick'#7#15'btnAddLineCli'
+'ck'#8'TabOrder'#2#1#0#0#7'TButton'#10'btnAddArea'#4'Left'#2'h'#6'Height'#2
+#24#3'Top'#2#8#5'Width'#2'4'#25'BorderSpacing.InnerBorder'#2#4#7'Caption'#6#4
+'Area'#7'OnClick'#7#15'btnAddAreaClick'#8'TabOrder'#2#2#0#0#7'TButton'#9'btn'
+'AddBar'#4'Left'#3#160#0#6'Height'#2#24#3'Top'#2#8#5'Width'#2'4'#25'BorderSp'
+'acing.InnerBorder'#2#4#7'Caption'#6#3'Bar'#7'OnClick'#7#14'btnAddBarClick'#8
+'TabOrder'#2#3#0#0#9'TCheckBox'#8'cbLegend'#4'Left'#3#128#1#6'Height'#2#17#3
+'Top'#2#8#5'Width'#2'8'#7'Caption'#6#6'Legend'#8'OnChange'#7#14'cbLegendChan'
+'ge'#8'TabOrder'#2#4#0#0#9'TCheckBox'#12'cbBottomAxis'#4'Left'#3#128#1#6'Hei'
+'ght'#2#17#3'Top'#2#24#5'Width'#2'K'#7'Caption'#6#11'Bottom Axis'#7'Checked'
+#9#8'OnChange'#7#18'cbBottomAxisChange'#5'State'#7#9'cbChecked'#8'TabOrder'#2
+#5#0#0#9'TCheckBox'#10'cbLeftAxis'#4'Left'#3#128#1#6'Height'#2#17#3'Top'#2'('
+#5'Width'#2'<'#7'Caption'#6#9'Left Axis'#7'Checked'#9#8'OnChange'#7#16'cbLef'
+'tAxisChange'#5'State'#7#9'cbChecked'#8'TabOrder'#2#6#0#0#9'TCheckBox'#7'cbT'
+'itle'#4'Left'#3#240#1#6'Height'#2#17#3'Top'#2#8#5'Width'#2'('#7'Caption'#6#5
+'Title'#7'Checked'#9#8'OnChange'#7#13'cbTitleChange'#5'State'#7#9'cbChecked'
+#8'TabOrder'#2#7#0#0#9'TCheckBox'#8'cbFooter'#4'Left'#3#240#1#6'Height'#2#17
+#3'Top'#2#24#5'Width'#2'2'#7'Caption'#6#6'Footer'#8'OnChange'#7#14'cbFooterC'
+'hange'#8'TabOrder'#2#8#0#0#9'TCheckBox'#10'cbInverted'#4'Left'#3#240#1#6'He'
+'ight'#2#17#3'Top'#2'('#5'Width'#2';'#7'Caption'#6#8'Inverted'#8'OnChange'#7
+#16'cbInvertedChange'#8'TabOrder'#2#9#0#0#7'TButton'#11'btnClearBar'#4'Left'
+#3#160#0#6'Height'#2#24#3'Top'#2'&'#5'Width'#2'4'#25'BorderSpacing.InnerBord'
+'er'#2#4#7'Caption'#6#3'Bar'#7'OnClick'#7#16'btnClearBarClick'#8'TabOrder'#2
+#10#0#0#7'TButton'#12'btnClearArea'#4'Left'#2'h'#6'Height'#2#24#3'Top'#2'&'#5
+'Width'#2'4'#25'BorderSpacing.InnerBorder'#2#4#7'Caption'#6#4'Area'#7'OnClic'
+'k'#7#17'btnClearAreaClick'#8'TabOrder'#2#11#0#0#7'TButton'#12'btnClearLine'
+#4'Left'#3#216#0#6'Height'#2#24#3'Top'#2'&'#5'Width'#2'4'#25'BorderSpacing.I'
+'nnerBorder'#2#4#7'Caption'#6#4'Line'#7'OnClick'#7#17'btnClearLineClick'#8'T'
,'abOrder'#2#12#0#0#7'TButton'#11'btnClearPie'#4'Left'#2'0'#6'Height'#2#24#3
+'Top'#2'&'#5'Width'#2'4'#25'BorderSpacing.InnerBorder'#2#4#7'Caption'#6#3'Pi'
+'e'#7'OnClick'#7#16'btnClearPieClick'#8'TabOrder'#2#13#0#0#9'TSpinEdit'#10'e'
+'dAddCount'#4'Left'#3' '#1#6'Height'#2#21#3'Top'#2#24#5'Width'#2'Z'#8'MaxVal'
+'ue'#4'@B'#15#0#8'MinValue'#2#1#8'TabOrder'#2#14#5'Value'#2#1#0#0#9'TCheckBo'
+'x'#18'cbShowGridCheckBox'#4'Left'#3#128#1#6'Height'#2#17#3'Top'#2'8'#5'Widt'
+'h'#2'F'#7'Caption'#6#10'Show grid '#7'Checked'#9#8'OnChange'#7#24'cbShowGri'
+'dCheckBoxChange'#5'State'#7#9'cbChecked'#8'TabOrder'#2#15#0#0#9'TCheckBox'
+#16'cbShowAxisTitles'#4'Left'#3#240#1#6'Height'#2#17#3'Top'#2'8'#5'Width'#2
+'?'#7'Caption'#6#11'Axis titles'#8'OnChange'#7#22'cbShowAxisTitlesChange'#8
+'TabOrder'#2#16#0#0#9'TComboBox'#11'cbMarkStyle'#4'Left'#3#132#0#6'Height'#2
+#21#3'Top'#2'L'#5'Width'#3#136#0#10'ItemHeight'#2#13#9'ItemIndex'#2#5#13'Ite'
+'ms.Strings'#1#6#9'smsCustom'#6#7'smsNone'#6#8'smsValue'#6#10'smsPercent'#6#8
+'smsLabel'#6#15'smsLabelPercent'#6#13'smsLabelValue'#6#9'smsLegend'#6#15'sms'
+'PercentTotal'#6#20'smsLabelPercentTotal'#6#9'smsXValue'#0#5'Style'#7#14'csD'
+'ropDownList'#8'TabOrder'#2#17#4'Text'#6#15'smsLabelPercent'#0#0#9'TComboBox'
+#10'cbReticule'#4'Left'#3#160#1#6'Height'#2#21#3'Top'#2'L'#5'Width'#3#136#0
+#10'ItemHeight'#2#13#9'ItemIndex'#2#0#13'Items.Strings'#1#6#6'rmNone'#6#10'r'
+'mVertical'#6#12'rmHorizontal'#6#7'rmCross'#0#8'OnChange'#7#16'cbReticuleCha'
+'nge'#5'Style'#7#14'csDropDownList'#8'TabOrder'#2#18#4'Text'#6#6'rmNone'#0#0
+#0#0
]);

View File

@ -20,8 +20,8 @@ type
btnAddPie: TButton;
btnAddLine: TButton;
btnAddArea: TButton;
cbReticule: TComboBox;
cbShowAxisTitles: TCheckBox;
cbShowReticule: TCheckBox;
Chart1: TChart;
cbBottomAxis: TCheckBox;
cbLeftAxis: TCheckBox;
@ -30,7 +30,6 @@ type
cbInverted: TCheckBox;
cbLegend: TCheckBox;
cbShowGridCheckBox: TCheckBox;
cbShowVertReticule: TCheckBox;
Chart1LineHor: TLine;
Chart1LineVert: TLine;
cbMarkStyle: TComboBox;
@ -38,6 +37,7 @@ type
lblAdd: TLabel;
lblMarkStyle: TLabel;
lblClear: TLabel;
lblReticule: TLabel;
Panel1: TPanel;
edAddCount: TSpinEdit;
procedure btnClearAreaClick(Sender: TObject);
@ -51,9 +51,8 @@ type
procedure btnAddPieClick(Sender: TObject);
procedure cbBottomAxisChange(Sender: TObject);
procedure cbLeftAxisChange(Sender: TObject);
procedure cbReticuleChange(Sender: TObject);
procedure cbShowAxisTitlesChange(Sender: TObject);
procedure cbShowReticuleChange(Sender: TObject);
procedure cbShowVertReticuleChange(Sender: TObject);
procedure cbTitleChange(Sender: TObject);
procedure cbFooterChange(Sender: TObject);
procedure cbLegendChange(Sender: TObject);
@ -179,6 +178,11 @@ begin
Chart1.Legend.Visible := cbLegend.Checked;
end;
procedure TForm1.cbReticuleChange(Sender: TObject);
begin
Chart1.ReticuleMode := TReticuleMode(cbReticule.ItemIndex);
end;
procedure TForm1.cbShowAxisTitlesChange(Sender: TObject);
begin
with Chart1.BottomAxis.Title do
@ -193,16 +197,6 @@ begin
Chart1.BottomAxis.Grid.Visible := cbShowGridCheckBox.Checked;
end;
procedure TForm1.cbShowReticuleChange(Sender: TObject);
begin
Chart1.ShowReticule := cbShowReticule.Checked;
end;
procedure TForm1.cbShowVertReticuleChange(Sender: TObject);
begin
Chart1.ShowVerticalReticule := cbShowVertReticule.Checked;
end;
procedure TForm1.cbLeftAxisChange(Sender: TObject);
begin
Chart1.LeftAxis.Visible := cbLeftAxis.Checked;

View File

@ -119,6 +119,7 @@ function FloatRangesOverlap(A, B, C, D: Double): Boolean; inline;
function PointDist(const A, B: TPoint): Integer; inline;
function PointDistX(const A, B: TPoint): Integer; inline;
function PointDistY(const A, B: TPoint): Integer; inline;
procedure RotateLabel(
Canvas: TCanvas; x, y: Integer; const St: String; RotDegree: Integer);
@ -248,6 +249,11 @@ begin
Result := Abs(A.X - B.X);
end;
function PointDistY(const A, B: TPoint): Integer; inline;
begin
Result := Abs(A.Y - B.Y);
end;
procedure RotateLabel(
Canvas: TCanvas; x, y: Integer; const St: String; RotDegree: Integer);
var

View File

@ -37,16 +37,14 @@ const
LEGEND_SPACING = 5;
type
TDrawVertReticule = procedure(
Sender: TComponent; IndexSerie, Index, Xi, Yi: Integer;
Xg, Yg: Double) of object;
TDrawReticule = procedure(
Sender: TComponent; IndexSerie, Index, Xi, Yi: Integer;
Xg, Yg: Double) of object;
TChart = class;
TReticuleMode = (rmNone, rmVertical, rmHorizontal, rmCross);
TDrawReticuleEvent = procedure(
ASender: TChart; ASeriesIndex, AIndex: Integer;
const AImg: TPoint; const AData: TDoublePoint) of object;
{ TBasicChartSeries }
TBasicChartSeries = class(TComponent)
@ -138,14 +136,9 @@ type
FSelectionRect: TRect;
FCurrentExtent: TDoubleRect;
FShowReticule: Boolean;
FShowVerticalReticule: Boolean;
FDrawVertReticule: TDrawVertReticule;
FDrawReticule: TDrawReticule;
FReticuleMode: TReticuleMode;
FOnDrawReticule: TDrawReticuleEvent;
FReticulePos: TPoint;
FVertReticuleX: Integer;
FFrame: TChartPen;
@ -160,6 +153,7 @@ type
procedure SetAutoUpdateXMax(Value: Boolean);
procedure SetAutoUpdateYMin(Value: Boolean);
procedure SetAutoUpdateYMax(Value: Boolean);
procedure SetReticuleMode(const AValue: TReticuleMode);
procedure SetXGraphMin(Value: Double);
procedure SetYGraphMin(Value: Double);
procedure SetXGraphMax(Value: Double);
@ -169,11 +163,7 @@ type
procedure SetTitle(Value: TChartTitle);
procedure SetFoot(Value: TChartTitle);
function GetLegendWidth(ACanvas: TCanvas): Integer;
procedure MaybeDrawReticules;
procedure DrawReticule(ACanvas: TCanvas; const APos: TPoint);
procedure DrawVerticalReticule(ACanvas: TCanvas; AX: Integer);
procedure SetShowVerticalReticule(AValue: Boolean);
procedure SetShowReticule(AValue: Boolean);
procedure DrawReticule(ACanvas: TCanvas);
procedure SetLegend(Value: TChartLegend);
procedure SetLeftAxis(Value: TChartAxis);
@ -193,10 +183,9 @@ type
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
procedure DoDrawVertReticule(
IndexSerie, Index: Integer; const APoint: TPoint; Xg, Yg: Double); virtual;
procedure DoDrawReticule(
IndexSerie, Index: Integer; const APoint: TPoint; Xg, Yg: Double); virtual;
ASeriesIndex, AIndex: Integer; const AImg: TPoint;
const AData: TDoublePoint); virtual;
public
XImageMin, YImageMin: Integer; // Image coordinates of limits
XImageMax, YImageMax: Integer;
@ -258,12 +247,12 @@ type
property YGraphMax: Double read FYGraphMax write SetYGraphMax;
property MirrorX: Boolean read FMirrorX write SetMirrorX;
property GraphBrush: TBrush read FGraphBrush write SetGraphBrush;
property ShowVerticalReticule: Boolean read FShowVerticalReticule write SetShowVerticalReticule;
property ShowReticule: Boolean read FShowReticule write SetShowReticule;
property ReticuleMode: TReticuleMode
read FReticuleMode write SetReticuleMode default rmNone;
property Series: TChartSeriesList read FSeries;
property OnDrawVertReticule: TDrawVertReticule read FDrawVertReticule write FDrawVertReticule;
property OnDrawReticule: TDrawReticule read FDrawReticule write FDrawReticule;
property OnDrawReticule: TDrawReticuleEvent
read FOnDrawReticule write FOnDrawReticule;
property Legend: TChartLegend read FLegend write SetLegend;
property Title: TChartTitle read FTitle write SetTitle;
@ -336,8 +325,8 @@ begin
Width := 400;
Height := 300;
FVertReticuleX := -1;
FReticulePos := Point(-1, -1);
FReticuleMode := rmNone;
FSeries := TChartSeriesList.Create(Self);
@ -358,8 +347,6 @@ begin
MirrorX := false;
FIsZoomed := false;
FShowReticule := false;
FShowVerticalReticule := false;
FBackColor := Color;
FGraphBrush := TBrush.Create;
@ -865,6 +852,14 @@ begin
Invalidate;
end;
procedure TChart.SetReticuleMode(const AValue: TReticuleMode);
begin
if FReticuleMode = AValue then exit;
DrawReticule(Canvas);
FReticuleMode := AValue;
Invalidate;
end;
procedure TChart.SetTitle(Value: TChartTitle);
begin
FTitle.Assign(Value);
@ -909,7 +904,7 @@ end;
procedure TChart.AddSeries(ASeries: TBasicChartSeries);
begin
MaybeDrawReticules;
DrawReticule(Canvas);
Series.FList.Add(ASeries);
ASeries.FChart := Self;
ASeries.AfterAdd;
@ -956,7 +951,7 @@ var
NBPointsMax: Integer;
XMinSeries, XMaxSeries, YMinSeries, YMaxSeries: Double;
begin
MaybeDrawReticules;
DrawReticule(ACanvas);
if FIsZoomed then begin
FXGraphMin := FCurrentExtent.a.X;
FYGraphMin := FCurrentExtent.a.Y;
@ -1030,7 +1025,7 @@ begin
DisplaySeries(ACanvas);
DrawTitleFoot(ACanvas, ARect);
if FLegend.Visible then DrawLegend(ACanvas, ARect);
MaybeDrawReticules;
DrawReticule(ACanvas);
end;
procedure TChart.XGraphToImage(Xin: Double; out XOut: Integer);
@ -1137,12 +1132,6 @@ begin
end;
end;
procedure TChart.MaybeDrawReticules;
begin
if FShowVerticalReticule then DrawVerticalReticule(Canvas, FVertReticuleX);
if FShowReticule then DrawReticule(Canvas, FReticulePos);
end;
procedure TChart.SaveToBitmapFile(const FileName: String);
var
tmpR: TRect;
@ -1199,38 +1188,13 @@ begin
SelectClipRgn(ACanvas.Handle, 0);
end;
procedure TChart.SetShowVerticalReticule(AValue: Boolean);
begin
if FShowVerticalReticule then begin
DrawVerticalReticule(Canvas, FVertReticuleX);
FShowVerticalReticule := false;
end;
FShowVerticalReticule := AValue;
Invalidate;
end;
procedure TChart.SetShowReticule(AValue: Boolean);
begin
if not AValue then
DrawReticule(Canvas, FReticulePos);
FShowReticule := AValue;
Invalidate;
end;
procedure TChart.DrawReticule(ACanvas: TCanvas; const APos: TPoint);
procedure TChart.DrawReticule(ACanvas: TCanvas);
begin
PrepareXorPen;
ACanvas.MoveTo(APos.X, YImageMin);
ACanvas.LineTo(APos.X, YImageMax);
ACanvas.MoveTo(XImageMin, APos.Y);
ACanvas.LineTo(XImageMax, APos.Y);
end;
procedure TChart.DrawVerticalReticule(ACanvas: TCanvas; AX: Integer);
begin
PrepareXorPen;
ACanvas.MoveTo(AX, YImageMin);
ACanvas.LineTo(AX, YImageMax);
if ReticuleMode in [rmVertical, rmCross] then
ACanvas.Line(FReticulePos.X, YImageMin, FReticulePos.X, YImageMax);
if ReticuleMode in [rmHorizontal, rmCross] then
ACanvas.Line(XImageMin, FReticulePos.Y, XImageMax, FReticulePos.Y);
end;
procedure TChart.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
@ -1245,47 +1209,41 @@ begin
end;
procedure TChart.MouseMove(Shift: TShiftState; X, Y: Integer);
const
DIST_FUNCS: array [TReticuleMode] of TPointDistFunc = (
nil, @PointDistX, @PointDistY, @PointDist);
var
i, pointIndex: Integer;
r: TRect;
pt, newRetPos: TPoint;
value: TDoublePoint;
begin
pt := Point(X, Y);
if FIsMouseDown then begin
PrepareXorPen;
Canvas.Rectangle(FSelectionRect);
FSelectionRect.BottomRight := Point(X, Y);
FSelectionRect.BottomRight := pt;
Canvas.Rectangle(FSelectionRect);
exit;
end;
if FReticuleMode = rmNone then exit;
r := Rect(XImageMin, YImageMin, XImageMax, YImageMax);
if r.Top > r.Bottom then
Exchange(r.Top, r.Bottom);
if r.Left > r.Right then
Exchange(r.Left, r.Right);
pt := Point(X, Y);
for i := 0 to SeriesCount - 1 do begin
if
FShowVerticalReticule and
Series[i].GetNearestPoint(@PointDistX, pt, pointIndex, newRetPos, value) and
(newRetPos.X <> FVertReticuleX) and
InRange(newRetPos.X, r.Left, r.Right)
then begin
DoDrawVertReticule(i, pointIndex, newRetPos, value.X, value.Y);
DrawVerticalReticule(Canvas, FVertReticuleX);
DrawVerticalReticule(Canvas, newRetPos.X);
FVertReticuleX := newRetPos.X;
end;
if
FShowReticule and
Series[i].GetNearestPoint(@PointDistX, pt, pointIndex, newRetPos, value) and
Series[i].GetNearestPoint(
DIST_FUNCS[FReticuleMode], pt, pointIndex, newRetPos, value) and
(newRetPos <> FReticulePos) and PtInRect(r, newRetPos)
then begin
DoDrawReticule(i, pointIndex, newRetPos, value.X, value.Y);
DrawReticule(Canvas, FReticulePos);
DrawReticule(Canvas, newRetPos);
DoDrawReticule(i, pointIndex, newRetPos, value);
DrawReticule(Canvas);
FReticulePos := newRetPos;
DrawReticule(Canvas);
end;
end;
end;
@ -1311,18 +1269,11 @@ begin
Invalidate;
end;
procedure TChart.DoDrawVertReticule(
IndexSerie, Index: Integer; const APoint: TPoint; Xg, Yg: Double);
begin
if Assigned(FDrawVertReticule) then
FDrawVertReticule(Self, IndexSerie, Index, APoint.X, APoint.Y, Xg, Yg);
end;
procedure TChart.DoDrawReticule(
IndexSerie, Index: Integer; const APoint: TPoint; Xg, Yg: Double);
ASeriesIndex, AIndex: Integer; const AImg: TPoint; const AData: TDoublePoint);
begin
if Assigned(FDrawReticule) then
FDrawReticule(Self, IndexSerie, Index, APoint.X, APoint.Y, Xg, Yg);
if Assigned(FOnDrawReticule) then
FOnDrawReticule(Self, ASeriesIndex, AIndex, AImg, AData);
end;
function TChart.GetNewColor: TColor;