LineSeriesCursor snaps out of points when dragged outside of window

A forum dedicated to WPF version of LightningChart Ultimate.

Moderator: Queue Moderators

Post Reply
MirroZV
Posts: 46
Joined: Wed May 13, 2020 10:41 am

LineSeriesCursor snaps out of points when dragged outside of window

Post by MirroZV » Mon May 06, 2024 5:15 am

Hello,

we stumbled upon simple issue with LineSeriesCursor that should snap to points. It is working well when you dragging and dropping cursor inside graph, but when you go outside of graph borders, it will not snap back to closest point. It will do that only when you zoom graph out enough to see current position of LineSeriesCursor. We have simple workaround for this in our application, so it is not big issue. Just so you know. Bellow is example code.


namespace Metrohm.Controls.Chart.Demo
{
using System.Windows.Controls;

using Arction.Wpf.ChartingMVVM;
using Arction.Wpf.ChartingMVVM.Axes;
using Arction.Wpf.ChartingMVVM.SeriesXY;
using Arction.Wpf.ChartingMVVM.Views.ViewXY;

public partial class LineSeriesCursorBug
{
public LineSeriesCursorBug()
{
InitializeComponent();

var chart = new LightningChart();

chart.BeginUpdate();

// Set chart control into the parent container.
(Content as Grid)!.Children.Add(chart);

chart.ViewXY.XAxes.Add(new AxisX());
chart.ViewXY.YAxes.Add(new AxisY());

var series = new PointLineSeries();
series.AddPoints(new[] { 1d, 2, 3 }, new[] { 1d, 2, 3 }, true);
chart.ViewXY.PointLineSeries.Add(series);

chart.ViewXY.LineSeriesCursors.Add(new LineSeriesCursor
{
ValueAtXAxis = 2,
SnapToPoints = true
});

chart.EndUpdate();
}
}
}

ArctionKestutis
Posts: 557
Joined: Mon Mar 14, 2016 9:22 am

Re: LineSeriesCursor snaps out of points when dragged outside of window

Post by ArctionKestutis » Tue May 07, 2024 9:46 am

Thank you for the report.
However, this particular issue is open for the interpretation - whatever it is a bug or a feature. I could imagine that user intentionally drags and drops LineSeriesCursor outside of chart/visible-range.
If don't want user to drag outside Chart, then use cursor.PositionChanged event handler to keep cursor inside (set Cursor.ValueAtXAxis property accordingly).

Post Reply