Bookstore

 Computer Math and Games in Pascal (preview) Lazarus Handbook

Recent

LemonParty

• Jr. Member
• Posts: 82
« on: July 24, 2024, 10:07:40 pm »
I have a line series. I added there few points over method AddXY. How can I read these points back?

wp

• Hero Member
• Posts: 12192
« Reply #1 on: July 24, 2024, 10:35:28 pm »
What do you mean? Read the values by code? Then call Series.XValue[point_index] and Series.YValue[point_index]. Or read the values by pointing or clicking at them with the mouse? In this case use a TDatapointHintTool, a TDatapointClickTool or a TDataPointCrosshairTool - see https://wiki.lazarus.freepascal.org/TAChart_Tutorial:_Chart_Tools, https://wiki.lazarus.freepascal.org/TAChart_documentation#Tools, or the sample project "tools" in the "demo" folder of the TAChart installation.

LemonParty

• Jr. Member
• Posts: 82
« Reply #2 on: July 25, 2024, 09:20:44 am »
Thank you for responce.
The second question remain.
User click in random place on graph. How can I determine the coordinate of click?

wp

• Hero Member
• Posts: 12192
« Reply #3 on: July 25, 2024, 11:21:12 am »
Write a handler for the chart's OnMouseDown event in which you convert the mouse coordinates to the chart's "graph coordinates" (Chart.ImageToGraph):

Code: Pascal  [Select][+][-]
1. uses
2.   TAChartUtils;
3.
4. procedure TForm1.Chart1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
5. var
6.   P: TDoublePoint;
7. begin
8.   P := Chart1.ImageToGraph(Point(X, Y));
9.   ShowMessage(Format('MouseDown at %d/%d --> %.3f/%.3f', [X, Y, P.X, P.Y]));
10. end;

• Jr. Member
• Posts: 82