Data-point hints for TAChart? lazarus / 55-TAChart ---------------------------------------------------------------------- dkjMusic · 2011-10-07 17:35 Is there a simple means whereby I can hover over a data point and display a hint with, e.g., the literature reference for that point? ---------------------------------------------------------------------- wp · 2011-10-07 17:57 These are the steps needed for your effect: - When adding the data to the series pass the literature reference for each point in the text parameter, e.g. Code: [Select]    Chart1LineSeries1.AddXY(x,y,ReferenceText, clRed);  - Add a ChartToolset to the form, and after doubleclicking on it, add a DataPointToolHit - Assign the ChartToolset to the corresponding Chart's property - Write a handler for the DataPointToolHint.OnHint event: Code: [Select]procedure TForm1.ChartToolset1DataPointHintTool1Hint(ATool: TDataPointHintTool;   const APoint: TPoint; var AHint: String); begin   AHint := TChartSeries(ATool.Series).Source.Item[ATool.PointIndex]^.Text; end; ---------------------------------------------------------------------- dkjMusic · 2011-10-07 20:58 Quote from: wp on October 07, 2011, 07:57:01 pmThese are the steps needed for your effect: - When adding the data to the series pass the literature reference for each point in the text parameter, e.g. Code: [Select]    Chart1LineSeries1.AddXY(x,y,ReferenceText, clRed);  - Add a ChartToolset to the form, and after doubleclicking on it, add a DataPointToolHit - Assign the ChartToolset to the corresponding Chart's property - Write a handler for the DataPointToolHint.OnHint event: Code: [Select]procedure TForm1.ChartToolset1DataPointHintTool1Hint(ATool: TDataPointHintTool;   const APoint: TPoint; var AHint: String); begin   AHint := TChartSeries(ATool.Series).Source.Item[ATool.PointIndex]^.Text; end; I did the above, except for AHint := TChartSeries..., I put AHint := TLineSeries... However, I still do not get the x,y's text as a hint. ---------------------------------------------------------------------- wp · 2011-10-07 21:28 Try the attached project, it's working. ---------------------------------------------------------------------- dkjMusic · 2011-10-07 23:47 Thanks for the example. I found my mistake - a Private declaration of the TLineSeries. I moved them Public and all worked just as you recommended. Thanks again very much. ---------------------------------------------------------------------- Ask · 2011-10-09 02:08 Minor note: in this particular case you can set Code: [Select]Chart1LineSeries1.Marks.Style:=smsLabel; Chart1LineSeries1.Marks.Visible:=false; ChartToolset1DataPointHintTool1.UseDefaultHintText:=true; ...and the hint will work without the need to handle OnHint event. See also http://wiki.lazarus.freepascal.org/TAChart_documentation#Data _point_hint_tool ---------------------------------------------------------------------- dkjMusic · 2011-10-09 06:04 Quote from: Ask on October 09, 2011, 04:08:05 amMinor note: in this particular case you can set Code: [Select]Chart1LineSeries1.Marks.Style:=smsLabel; Chart1LineSeries1.Marks.Visible:=false; ChartToolset1DataPointHintTool1.UseDefaultHintText:=true; ...and the hint will work without the need to handle OnHint event. See also http://wiki.lazarus.freepascal.org/TAChart_documentation#Data _point_hint_tool Yes, thanks Ask.