TAChart: Allow to use reticule for area and bar series.

* Move TLineSeries.GetNearestPoint implementation to TBasicPointSeries class
* Add UseReticule property, default it to true for line series
* Update demo

git-svn-id: trunk@22011 -
This commit is contained in:
ask 2009-10-03 23:12:38 +00:00
parent 6603b29d3b
commit 63b043a6c4
4 changed files with 126 additions and 105 deletions

View File

@ -51,17 +51,17 @@ object Form1: TForm1
Align = alClient Align = alClient
ParentColor = False ParentColor = False
object Chart1LineHor: TLine object Chart1LineHor: TLine
ShowInLegend = False
Pen.Style = psDash Pen.Style = psDash
Position = 0 Position = 0
SeriesColor = clBlack SeriesColor = clBlack
ShowInLegend = False
end end
object Chart1LineVert: TLine object Chart1LineVert: TLine
ShowInLegend = False
LineStyle = lsVertical LineStyle = lsVertical
Pen.Style = psDash Pen.Style = psDash
Position = 0 Position = 0
SeriesColor = clBlack SeriesColor = clBlack
ShowInLegend = False
end end
end end
object Panel1: TPanel object Panel1: TPanel

View File

@ -1,84 +1,87 @@
{ This is an automatically generated lazarus resource file }
LazarusResources.Add('TForm1','FORMDATA',[ 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' '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' +'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.29'#0#6'TCha' +#3'I'#2#8'Position'#7#14'poScreenCenter'#10'LCLVersion'#6#6'0.9.29'#0#6'TCha'
+'rt'#6'Chart1'#4'Left'#2#0#6'Height'#3#136#1#3'Top'#2#0#5'Width'#3'I'#2#8'Ax' +'rt'#6'Chart1'#4'Left'#2#0#6'Height'#3#136#1#3'Top'#2#0#5'Width'#3'I'#2#8'Ax'
+'isList'#14#1#9'Alignment'#7#7'calLeft'#10'Grid.Color'#7#6'clGray'#6'Offset' +'isList'#14#1#9'Alignment'#7#7'calLeft'#10'Grid.Color'#7#6'clGray'#6'Offset'
+#2#0#5'Scale'#2#1#17'Title.Font.Height'#2#245#15'Title.Font.Name'#6#13'MS Sa' +#5#0#0#0#0#0#0#0#0#0#0#5'Scale'#5#0#0#0#0#0#0#0#128#255'?'#17'Title.Font.Hei'
+'ns Serif'#0#1#9'Alignment'#7#9'calBottom'#10'Grid.Color'#7#6'clGray'#6'Offs' +'ght'#2#245#15'Title.Font.Name'#6#13'MS Sans Serif'#0#1#9'Alignment'#7#9'cal'
+'et'#2#0#5'Scale'#2#1#17'Title.Font.Height'#2#245#15'Title.Font.Name'#6#13'M' +'Bottom'#10'Grid.Color'#7#6'clGray'#6'Offset'#5#0#0#0#0#0#0#0#0#0#0#5'Scale'
+'S Sans Serif'#0#0#16'Foot.Brush.Color'#7#9'clBtnFace'#15'Foot.Font.Color'#7 +#5#0#0#0#0#0#0#0#128#255'?'#17'Title.Font.Height'#2#245#15'Title.Font.Name'#6
+#5'clRed'#16'Foot.Font.Height'#2#243#14'Foot.Font.Name'#6#13'MS Sans Serif' +#13'MS Sans Serif'#0#0#16'Foot.Brush.Color'#7#9'clBtnFace'#15'Foot.Font.Colo'
+#15'Foot.Font.Style'#11#6'fsBold'#0#17'Foot.Text.Strings'#1#6#25'This a Left' +'r'#7#5'clRed'#16'Foot.Font.Height'#2#243#14'Foot.Font.Name'#6#13'MS Sans Se'
+'Aligned Footer'#0#18'Legend.Font.Height'#2#245#16'Legend.Font.Name'#6#13'MS' +'rif'#15'Foot.Font.Style'#11#6'fsBold'#0#17'Foot.Text.Strings'#1#6#25'This a'
+' Sans Serif'#17'Title.Brush.Color'#7#9'clBtnFace'#16'Title.Font.Color'#7#6 +' LeftAligned Footer'#0#18'Legend.Font.Height'#2#245#16'Legend.Font.Name'#6
+'clBlue'#17'Title.Font.Height'#2#245#15'Title.Font.Name'#6#13'MS Sans Serif' +#13'MS Sans Serif'#17'Title.Brush.Color'#7#9'clBtnFace'#16'Title.Font.Color'
+#18'Title.Text.Strings'#1#6#20'Centered Chart Title'#0#13'Title.Visible'#9#5 +#7#6'clBlue'#17'Title.Font.Height'#2#245#15'Title.Font.Name'#6#13'MS Sans Se'
+'Align'#7#8'alClient'#11'ParentColor'#8#0#5'TLine'#13'Chart1LineHor'#12'Show' +'rif'#18'Title.Text.Strings'#1#6#20'Centered Chart Title'#0#13'Title.Visible'
+'InLegend'#8#9'Pen.Style'#7#6'psDash'#8'Position'#2#0#11'SeriesColor'#7#7'cl' +#9#5'Align'#7#8'alClient'#11'ParentColor'#8#0#5'TLine'#13'Chart1LineHor'#9'P'
+'Black'#0#0#5'TLine'#14'Chart1LineVert'#12'ShowInLegend'#8#9'LineStyle'#7#10 +'en.Style'#7#6'psDash'#8'Position'#5#0#0#0#0#0#0#0#0#0#0#11'SeriesColor'#7#7
+'lsVertical'#9'Pen.Style'#7#6'psDash'#8'Position'#2#0#11'SeriesColor'#7#7'cl' +'clBlack'#12'ShowInLegend'#8#0#0#5'TLine'#14'Chart1LineVert'#9'LineStyle'#7
+'Black'#0#0#0#6'TPanel'#6'Panel1'#4'Left'#2#0#6'Height'#2'f'#3'Top'#3#136#1#5 +#10'lsVertical'#9'Pen.Style'#7#6'psDash'#8'Position'#5#0#0#0#0#0#0#0#0#0#0#11
+'Width'#3'I'#2#5'Align'#7#8'alBottom'#12'ClientHeight'#2'f'#11'ClientWidth'#3 +'SeriesColor'#7#7'clBlack'#12'ShowInLegend'#8#0#0#0#6'TPanel'#6'Panel1'#4'Le'
+'I'#2#8'TabOrder'#2#0#0#6'TLabel'#6'lblAdd'#4'Left'#2#13#6'Height'#2#14#3'To' +'ft'#2#0#6'Height'#2'f'#3'Top'#3#136#1#5'Width'#3'I'#2#5'Align'#7#8'alBottom'
+'p'#2#10#5'Width'#2#24#7'Caption'#6#4'Add:'#11'ParentColor'#8#0#0#6'TLabel'#8 +#12'ClientHeight'#2'f'#11'ClientWidth'#3'I'#2#8'TabOrder'#2#0#0#6'TLabel'#6
+'lblClear'#4'Left'#2#13#6'Height'#2#14#3'Top'#2'('#5'Width'#2#30#7'Caption'#6 +'lblAdd'#4'Left'#2#13#6'Height'#2#14#3'Top'#2#10#5'Width'#2#24#7'Caption'#6#4
+#6'Clear:'#11'ParentColor'#8#0#0#6'TLabel'#11'lblAddCount'#4'Left'#3' '#1#6 +'Add:'#11'ParentColor'#8#0#0#6'TLabel'#8'lblClear'#4'Left'#2#13#6'Height'#2
+'Height'#2#14#3'Top'#2#8#5'Width'#2':'#7'Caption'#6#12'Multiple add'#11'Pare' +#14#3'Top'#2'('#5'Width'#2#30#7'Caption'#6#6'Clear:'#11'ParentColor'#8#0#0#6
+'ntColor'#8#0#0#6'TLabel'#12'lblMarkStyle'#4'Left'#2'0'#6'Height'#2#14#3'Top' +'TLabel'#11'lblAddCount'#4'Left'#3' '#1#6'Height'#2#14#3'Top'#2#8#5'Width'#2
+#2'P'#5'Width'#2'N'#7'Caption'#6#15'Add with marks:'#11'ParentColor'#8#0#0#6 +':'#7'Caption'#6#12'Multiple add'#11'ParentColor'#8#0#0#6'TLabel'#12'lblMark'
+'TLabel'#11'lblReticule'#4'Left'#3'h'#1#6'Height'#2#14#3'Top'#2'P'#5'Width'#2 +'Style'#4'Left'#2'0'#6'Height'#2#14#3'Top'#2'P'#5'Width'#2'N'#7'Caption'#6#15
+'+'#7'Caption'#6#9'Reticule:'#11'ParentColor'#8#0#0#7'TButton'#9'btnAddPie'#4 +'Add with marks:'#11'ParentColor'#8#0#0#6'TLabel'#11'lblReticule'#4'Left'#3
+'Left'#2'0'#6'Height'#2#24#3'Top'#2#8#5'Width'#2'4'#25'BorderSpacing.InnerBo' +'h'#1#6'Height'#2#14#3'Top'#2'P'#5'Width'#2'+'#7'Caption'#6#9'Reticule:'#11
+'rder'#2#4#7'Caption'#6#3'Pie'#7'OnClick'#7#14'btnAddPieClick'#8'TabOrder'#2 +'ParentColor'#8#0#0#7'TButton'#9'btnAddPie'#4'Left'#2'0'#6'Height'#2#24#3'To'
+#0#0#0#7'TButton'#10'btnAddLine'#4'Left'#3#216#0#6'Height'#2#24#3'Top'#2#8#5 +'p'#2#8#5'Width'#2'4'#25'BorderSpacing.InnerBorder'#2#4#7'Caption'#6#3'Pie'#7
+'Width'#2'4'#25'BorderSpacing.InnerBorder'#2#4#7'Caption'#6#4'Line'#7'OnClic' +'OnClick'#7#14'btnAddPieClick'#8'TabOrder'#2#0#0#0#7'TButton'#10'btnAddLine'
+'k'#7#15'btnAddLineClick'#8'TabOrder'#2#1#0#0#7'TButton'#10'btnAddArea'#4'Le' +#4'Left'#3#216#0#6'Height'#2#24#3'Top'#2#8#5'Width'#2'4'#25'BorderSpacing.In'
+'ft'#2'h'#6'Height'#2#24#3'Top'#2#8#5'Width'#2'4'#25'BorderSpacing.InnerBord' +'nerBorder'#2#4#7'Caption'#6#4'Line'#7'OnClick'#7#15'btnAddLineClick'#8'TabO'
+'er'#2#4#7'Caption'#6#4'Area'#7'OnClick'#7#15'btnAddAreaClick'#8'TabOrder'#2 +'rder'#2#1#0#0#7'TButton'#10'btnAddArea'#4'Left'#2'h'#6'Height'#2#24#3'Top'#2
+#2#0#0#7'TButton'#9'btnAddBar'#4'Left'#3#160#0#6'Height'#2#24#3'Top'#2#8#5'W' +#8#5'Width'#2'4'#25'BorderSpacing.InnerBorder'#2#4#7'Caption'#6#4'Area'#7'On'
+'idth'#2'4'#25'BorderSpacing.InnerBorder'#2#4#7'Caption'#6#3'Bar'#7'OnClick' +'Click'#7#15'btnAddAreaClick'#8'TabOrder'#2#2#0#0#7'TButton'#9'btnAddBar'#4
+#7#14'btnAddBarClick'#8'TabOrder'#2#3#0#0#9'TCheckBox'#8'cbLegend'#4'Left'#3 +'Left'#3#160#0#6'Height'#2#24#3'Top'#2#8#5'Width'#2'4'#25'BorderSpacing.Inne'
+#128#1#6'Height'#2#17#3'Top'#2#8#5'Width'#2'7'#7'Caption'#6#6'Legend'#8'OnCh' +'rBorder'#2#4#7'Caption'#6#3'Bar'#7'OnClick'#7#14'btnAddBarClick'#8'TabOrder'
+'ange'#7#14'cbLegendChange'#8'TabOrder'#2#4#0#0#9'TCheckBox'#12'cbBottomAxis' +#2#3#0#0#9'TCheckBox'#8'cbLegend'#4'Left'#3#128#1#6'Height'#2#17#3'Top'#2#8#5
+#4'Left'#3#128#1#6'Height'#2#17#3'Top'#2#24#5'Width'#2'M'#7'Caption'#6#11'Bo' +'Width'#2'7'#7'Caption'#6#6'Legend'#8'OnChange'#7#14'cbLegendChange'#8'TabOr'
+'ttom Axis'#7'Checked'#9#8'OnChange'#7#18'cbBottomAxisChange'#5'State'#7#9'c' +'der'#2#4#0#0#9'TCheckBox'#12'cbBottomAxis'#4'Left'#3#128#1#6'Height'#2#17#3
+'bChecked'#8'TabOrder'#2#5#0#0#9'TCheckBox'#10'cbLeftAxis'#4'Left'#3#128#1#6 +'Top'#2#24#5'Width'#2'M'#7'Caption'#6#11'Bottom Axis'#7'Checked'#9#8'OnChang'
+'Height'#2#17#3'Top'#2'('#5'Width'#2'>'#7'Caption'#6#9'Left Axis'#7'Checked' +'e'#7#18'cbBottomAxisChange'#5'State'#7#9'cbChecked'#8'TabOrder'#2#5#0#0#9'T'
+#9#8'OnChange'#7#16'cbLeftAxisChange'#5'State'#7#9'cbChecked'#8'TabOrder'#2#6 +'CheckBox'#10'cbLeftAxis'#4'Left'#3#128#1#6'Height'#2#17#3'Top'#2'('#5'Width'
+#0#0#9'TCheckBox'#7'cbTitle'#4'Left'#3#240#1#6'Height'#2#17#3'Top'#2#8#5'Wid' +#2'>'#7'Caption'#6#9'Left Axis'#7'Checked'#9#8'OnChange'#7#16'cbLeftAxisChan'
+'th'#2'('#7'Caption'#6#5'Title'#7'Checked'#9#8'OnChange'#7#13'cbTitleChange' +'ge'#5'State'#7#9'cbChecked'#8'TabOrder'#2#6#0#0#9'TCheckBox'#7'cbTitle'#4'L'
+#5'State'#7#9'cbChecked'#8'TabOrder'#2#7#0#0#9'TCheckBox'#8'cbFooter'#4'Left' +'eft'#3#240#1#6'Height'#2#17#3'Top'#2#8#5'Width'#2'('#7'Caption'#6#5'Title'#7
+#3#240#1#6'Height'#2#17#3'Top'#2#24#5'Width'#2'4'#7'Caption'#6#6'Footer'#8'O' +'Checked'#9#8'OnChange'#7#13'cbTitleChange'#5'State'#7#9'cbChecked'#8'TabOrd'
+'nChange'#7#14'cbFooterChange'#8'TabOrder'#2#8#0#0#9'TCheckBox'#10'cbInverte' +'er'#2#7#0#0#9'TCheckBox'#8'cbFooter'#4'Left'#3#240#1#6'Height'#2#17#3'Top'#2
+'d'#4'Left'#3#240#1#6'Height'#2#17#3'Top'#2'('#5'Width'#2'>'#7'Caption'#6#8 +#24#5'Width'#2'4'#7'Caption'#6#6'Footer'#8'OnChange'#7#14'cbFooterChange'#8
+'Inverted'#8'OnChange'#7#16'cbInvertedChange'#8'TabOrder'#2#9#0#0#7'TButton' +'TabOrder'#2#8#0#0#9'TCheckBox'#10'cbInverted'#4'Left'#3#240#1#6'Height'#2#17
+#11'btnClearBar'#4'Left'#3#160#0#6'Height'#2#24#3'Top'#2'&'#5'Width'#2'4'#25 +#3'Top'#2'('#5'Width'#2'>'#7'Caption'#6#8'Inverted'#8'OnChange'#7#16'cbInver'
+'BorderSpacing.InnerBorder'#2#4#7'Caption'#6#3'Bar'#7'OnClick'#7#16'btnClear' +'tedChange'#8'TabOrder'#2#9#0#0#7'TButton'#11'btnClearBar'#4'Left'#3#160#0#6
+'BarClick'#8'TabOrder'#2#10#0#0#7'TButton'#12'btnClearArea'#4'Left'#2'h'#6'H' +'Height'#2#24#3'Top'#2'&'#5'Width'#2'4'#25'BorderSpacing.InnerBorder'#2#4#7
+'eight'#2#24#3'Top'#2'&'#5'Width'#2'4'#25'BorderSpacing.InnerBorder'#2#4#7'C' +'Caption'#6#3'Bar'#7'OnClick'#7#16'btnClearBarClick'#8'TabOrder'#2#10#0#0#7
+'aption'#6#4'Area'#7'OnClick'#7#17'btnClearAreaClick'#8'TabOrder'#2#11#0#0#7 +'TButton'#12'btnClearArea'#4'Left'#2'h'#6'Height'#2#24#3'Top'#2'&'#5'Width'#2
+'TButton'#12'btnClearLine'#4'Left'#3#216#0#6'Height'#2#24#3'Top'#2'&'#5'Widt' +'4'#25'BorderSpacing.InnerBorder'#2#4#7'Caption'#6#4'Area'#7'OnClick'#7#17'b'
+'h'#2'4'#25'BorderSpacing.InnerBorder'#2#4#7'Caption'#6#4'Line'#7'OnClick'#7 +'tnClearAreaClick'#8'TabOrder'#2#11#0#0#7'TButton'#12'btnClearLine'#4'Left'#3
+#17'btnClearLineClick'#8'TabOrder'#2#12#0#0#7'TButton'#11'btnClearPie'#4'Lef' +#216#0#6'Height'#2#24#3'Top'#2'&'#5'Width'#2'4'#25'BorderSpacing.InnerBorder'
+'t'#2'0'#6'Height'#2#24#3'Top'#2'&'#5'Width'#2'4'#25'BorderSpacing.InnerBord' +#2#4#7'Caption'#6#4'Line'#7'OnClick'#7#17'btnClearLineClick'#8'TabOrder'#2#12
+'er'#2#4#7'Caption'#6#3'Pie'#7'OnClick'#7#16'btnClearPieClick'#8'TabOrder'#2 +#0#0#7'TButton'#11'btnClearPie'#4'Left'#2'0'#6'Height'#2#24#3'Top'#2'&'#5'Wi'
,#13#0#0#9'TSpinEdit'#10'edAddCount'#4'Left'#3' '#1#6'Height'#2#21#3'Top'#2#24 ,'dth'#2'4'#25'BorderSpacing.InnerBorder'#2#4#7'Caption'#6#3'Pie'#7'OnClick'#7
+#5'Width'#2'Z'#8'MaxValue'#4'@B'#15#0#8'MinValue'#2#1#8'TabOrder'#2#14#5'Val' +#16'btnClearPieClick'#8'TabOrder'#2#13#0#0#9'TSpinEdit'#10'edAddCount'#4'Lef'
+'ue'#2#1#0#0#9'TCheckBox'#18'cbShowGridCheckBox'#4'Left'#3#128#1#6'Height'#2 +'t'#3' '#1#6'Height'#2#21#3'Top'#2#24#5'Width'#2'Z'#8'MaxValue'#4'@B'#15#0#8
+#17#3'Top'#2'8'#5'Width'#2'F'#7'Caption'#6#10'Show grid '#7'Checked'#9#8'OnC' +'MinValue'#2#1#8'TabOrder'#2#14#5'Value'#2#1#0#0#9'TCheckBox'#18'cbShowGridC'
+'hange'#7#24'cbShowGridCheckBoxChange'#5'State'#7#9'cbChecked'#8'TabOrder'#2 +'heckBox'#4'Left'#3#128#1#6'Height'#2#17#3'Top'#2'8'#5'Width'#2'F'#7'Caption'
+#15#0#0#9'TCheckBox'#16'cbShowAxisTitles'#4'Left'#3#240#1#6'Height'#2#17#3'T' +#6#10'Show grid '#7'Checked'#9#8'OnChange'#7#24'cbShowGridCheckBoxChange'#5
+'op'#2'8'#5'Width'#2'B'#7'Caption'#6#11'Axis titles'#8'OnChange'#7#22'cbShow' +'State'#7#9'cbChecked'#8'TabOrder'#2#15#0#0#9'TCheckBox'#16'cbShowAxisTitles'
+'AxisTitlesChange'#8'TabOrder'#2#16#0#0#9'TComboBox'#11'cbMarkStyle'#4'Left' +#4'Left'#3#240#1#6'Height'#2#17#3'Top'#2'8'#5'Width'#2'B'#7'Caption'#6#11'Ax'
+#3#132#0#6'Height'#2#21#3'Top'#2'L'#5'Width'#3#136#0#10'ItemHeight'#2#13#9'I' +'is titles'#8'OnChange'#7#22'cbShowAxisTitlesChange'#8'TabOrder'#2#16#0#0#9
+'temIndex'#2#5#13'Items.Strings'#1#6#9'smsCustom'#6#7'smsNone'#6#8'smsValue' +'TComboBox'#11'cbMarkStyle'#4'Left'#3#132#0#6'Height'#2#21#3'Top'#2'L'#5'Wid'
+#6#10'smsPercent'#6#8'smsLabel'#6#15'smsLabelPercent'#6#13'smsLabelValue'#6#9 +'th'#3#136#0#10'ItemHeight'#2#13#9'ItemIndex'#2#5#13'Items.Strings'#1#6#9'sm'
+'smsLegend'#6#15'smsPercentTotal'#6#20'smsLabelPercentTotal'#6#9'smsXValue'#0 +'sCustom'#6#7'smsNone'#6#8'smsValue'#6#10'smsPercent'#6#8'smsLabel'#6#15'sms'
+#5'Style'#7#14'csDropDownList'#8'TabOrder'#2#17#4'Text'#6#15'smsLabelPercent' +'LabelPercent'#6#13'smsLabelValue'#6#9'smsLegend'#6#15'smsPercentTotal'#6#20
+#0#0#9'TComboBox'#10'cbReticule'#4'Left'#3#160#1#6'Height'#2#21#3'Top'#2'L'#5 +'smsLabelPercentTotal'#6#9'smsXValue'#0#5'Style'#7#14'csDropDownList'#8'TabO'
+'Width'#3#136#0#10'ItemHeight'#2#13#9'ItemIndex'#2#0#13'Items.Strings'#1#6#6 +'rder'#2#17#4'Text'#6#15'smsLabelPercent'#0#0#9'TComboBox'#10'cbReticule'#4
+'rmNone'#6#10'rmVertical'#6#12'rmHorizontal'#6#7'rmCross'#0#8'OnChange'#7#16 +'Left'#3#160#1#6'Height'#2#21#3'Top'#2'L'#5'Width'#3#136#0#10'ItemHeight'#2
+'cbReticuleChange'#5'Style'#7#14'csDropDownList'#8'TabOrder'#2#18#4'Text'#6#6 +#13#9'ItemIndex'#2#0#13'Items.Strings'#1#6#6'rmNone'#6#10'rmVertical'#6#12'r'
+'rmNone'#0#0#0#0 +'mHorizontal'#6#7'rmCross'#0#8'OnChange'#7#16'cbReticuleChange'#5'Style'#7#14
+'csDropDownList'#8'TabOrder'#2#18#4'Text'#6#6'rmNone'#0#0#0#0
]); ]);

View File

@ -102,6 +102,7 @@ begin
else Y3 := Y3 - random(5); else Y3 := Y3 - random(5);
FArea.AddXY(x3, y3, '', clTAColor); FArea.AddXY(x3, y3, '', clTAColor);
end; end;
FArea.UseReticule := true;
end; end;
procedure TForm1.btnAddBarClick(Sender: TObject); procedure TForm1.btnAddBarClick(Sender: TObject);

View File

@ -40,12 +40,22 @@ type
TBasicPointSeries = class(TChartSeries) TBasicPointSeries = class(TChartSeries)
private private
FPrevLabelRect: TRect; FPrevLabelRect: TRect;
procedure SetUseReticule(AValue: Boolean);
protected protected
FUseReticule: Boolean;
procedure DrawLabel( procedure DrawLabel(
ACanvas: TCanvas; AIndex: Integer; const ADataPoint: TPoint; ACanvas: TCanvas; AIndex: Integer; const ADataPoint: TPoint;
ADown: Boolean); ADown: Boolean);
procedure DrawLabels(ACanvas: TCanvas; ADrawDown: Boolean); procedure DrawLabels(ACanvas: TCanvas; ADrawDown: Boolean);
function GetNearestPoint(
ADistFunc: TPointDistFunc; const APoint: TPoint;
out AIndex: Integer; out AImg: TPoint; out AValue: TDoublePoint): Boolean;
override;
procedure UpdateMargins(ACanvas: TCanvas; var AMargins: TRect); override; procedure UpdateMargins(ACanvas: TCanvas; var AMargins: TRect); override;
property UseReticule: Boolean
read FUseReticule write SetUseReticule default false;
end; end;
{ TBarSeries } { TBarSeries }
@ -78,6 +88,7 @@ type
property Depth; property Depth;
property SeriesColor; property SeriesColor;
property Source; property Source;
property UseReticule;
end; end;
{ TPieSeries } { TPieSeries }
@ -131,6 +142,7 @@ type
property SeriesColor; property SeriesColor;
property Source; property Source;
property Stairs: Boolean read FStairs write SetStairs default false; property Stairs: Boolean read FStairs write SetStairs default false;
property UseReticule;
end; end;
TSeriesPointerDrawEvent = procedure ( TSeriesPointerDrawEvent = procedure (
@ -158,10 +170,6 @@ type
protected protected
procedure AfterAdd; override; procedure AfterAdd; override;
procedure GetLegendItems(AItems: TChartLegendItems); override; procedure GetLegendItems(AItems: TChartLegendItems); override;
function GetNearestPoint(
ADistFunc: TPointDistFunc; const APoint: TPoint;
out AIndex: Integer; out AImg: TPoint; out AValue: TDoublePoint): Boolean;
override;
function GetSeriesColor: TColor; override; function GetSeriesColor: TColor; override;
procedure SetSeriesColor(const AValue: TColor); override; procedure SetSeriesColor(const AValue: TColor); override;
public public
@ -186,6 +194,7 @@ type
property ShowPoints: Boolean property ShowPoints: Boolean
read FShowPoints write SetShowPoints default false; read FShowPoints write SetShowPoints default false;
property Source; property Source;
property UseReticule default true;
end; end;
// 'TSerie' alias is for compatibility with older versions of TAChart. // 'TSerie' alias is for compatibility with older versions of TAChart.
@ -324,6 +333,7 @@ begin
FLinePen.OnChange := @StyleChanged; FLinePen.OnChange := @StyleChanged;
FLineType := ltFromPrevious; FLineType := ltFromPrevious;
FPointer := TSeriesPointer.Create(FChart); FPointer := TSeriesPointer.Create(FChart);
FUseReticule := true;
end; end;
destructor TLineSeries.Destroy; destructor TLineSeries.Destroy;
@ -391,28 +401,6 @@ begin
AItems.Add(TLegendItemLine.Create(LinePen, Title)); AItems.Add(TLegendItemLine.Create(LinePen, Title));
end; end;
function TLineSeries.GetNearestPoint(
ADistFunc: TPointDistFunc; const APoint: TPoint;
out AIndex: Integer; out AImg: TPoint; out AValue: TDoublePoint): Boolean;
var
dist, minDist, i: Integer;
pt: TPoint;
begin
Result := Count > 0;
minDist := MaxInt;
for i := 0 to Count - 1 do begin
pt := Point(GetXImgValue(i), GetYImgValue(i));
dist := ADistFunc(APoint, pt);
if dist >= minDist then
Continue;
minDist := dist;
AIndex := i;
AImg := pt;
AValue.X := GetXValue(i);
AValue.Y := GetYValue(i);
end;
end;
function TLineSeries.GetSeriesColor: TColor; function TLineSeries.GetSeriesColor: TColor;
begin begin
Result := FLinePen.Color; Result := FLinePen.Color;
@ -598,6 +586,35 @@ begin
end; end;
end; end;
function TBasicPointSeries.GetNearestPoint(
ADistFunc: TPointDistFunc; const APoint: TPoint;
out AIndex: Integer; out AImg: TPoint; out AValue: TDoublePoint): Boolean;
var
dist, minDist, i: Integer;
pt: TPoint;
begin
Result := UseReticule and (Count > 0);
minDist := MaxInt;
for i := 0 to Count - 1 do begin
pt := Point(GetXImgValue(i), GetYImgValue(i));
dist := ADistFunc(APoint, pt);
if dist >= minDist then
Continue;
minDist := dist;
AIndex := i;
AImg := pt;
AValue.X := GetXValue(i);
AValue.Y := GetYValue(i);
end;
end;
procedure TBasicPointSeries.SetUseReticule(AValue: Boolean);
begin
if FUseReticule = AValue then exit;
FUseReticule := AValue;
UpdateParentChart;
end;
procedure TBasicPointSeries.UpdateMargins(ACanvas: TCanvas; var AMargins: TRect); procedure TBasicPointSeries.UpdateMargins(ACanvas: TCanvas; var AMargins: TRect);
var var
h: Integer; h: Integer;