Marcus
Marcus

Reputation: 199

How to get the coordinates of a point selected by the mouse in the series of LiveCharts?

I drew a line graph using livecharts. The plot is very easy. But now I have a problem about how to get the coordinates of a point selected by the mouse in the series of LiveCharts. I know Livecharts could show the coordinates of a point near the mouse on a tooltip, but I didn't find how to get the value showed on the tooltip. Is there any function to return the values? Thanks! Besides, could Livecharts hightlight the point selected by mouse? Thanks!

Upvotes: 0

Views: 1304

Answers (1)

Andy
Andy

Reputation: 12276

You could try using the dataclick event.

https://github.com/Live-Charts/Live-Charts/blob/master/WpfView/Charts/Base/Chart.cs

From:

https://github.com/Live-Charts/Live-Charts/issues/42

The author explains how to do what seems to be your requirement:

 <lvc:LineChart DataClick="Chart_OnDataClick">

and

private void Chart_OnDataClick(ChartPoint point) 
{
   MessageBox.Show("you clicked (" + point.X + "," + point.Y + ")");

   // point.Instance contains the value as object, in case you passed a class, or any other type
}

Upvotes: 1

Related Questions