Forum > TAChart
Read points from TLineSeries
(1/1)
LemonParty:
I have a line series. I added there few points over method AddXY. How can I read these points back?
wp:
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:
Thank you for responce.
The second question remain.
User click in random place on graph. How can I determine the coordinate of click?
wp:
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 [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---uses TAChartUtils; procedure TForm1.Chart1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);var P: TDoublePoint;begin P := Chart1.ImageToGraph(Point(X, Y)); ShowMessage(Format('MouseDown at %d/%d --> %.3f/%.3f', [X, Y, P.X, P.Y]));end;
LemonParty:
Thank you. It works.
Navigation
[0] Message Index