beto-rodriguez / LiveCharts2

Simple, flexible, interactive & powerful charts, maps and gauges for .Net, LiveCharts2 can now practically run everywhere Maui, Uno Platform, Blazor-wasm, WPF, WinForms, Xamarin, Avalonia, WinUI, UWP.
https://livecharts.dev
MIT License
4.38k stars 572 forks source link

Can a chart implement dragging of a specific data point? #1543

Closed JusterZhu closed 2 months ago

JusterZhu commented 4 months ago

I am using the CartesianChart control from LiveCharts2 in a WPF application. I would like to implement the ability to drag any data point with the mouse to modify its position.

beto-rodriguez commented 2 months ago

Hi, this is an interesting example; to achieve that, you first need to know which point was clicked:

https://livecharts.dev/docs/Maui/2.0.0-rc2/samples.events.cartesian

Then when the pointer goes up, you must convert the position to the chart coordinate system:

https://livecharts.dev/docs/Maui/2.0.0-rc2/samples.events.addPointOnClick

That should be the way, but let me know if there is something else, I can help you with, I will move this to a discussion in case you need further assistance.