-
Notifications
You must be signed in to change notification settings - Fork 981
Closed
Labels
BUGunexpected behaviorunexpected behavior
Description
Bug Report
Issue: SignalPlot.GetPointNearestX returns incorrect pointIndex
This issue started after upgrading from v4.1.52 to v4.1.54
Change#1946 seems to have broken it.
v4,1,52 used SamplePeriod
v4.1.54 uses SampleRate
Reproducing: Use AddSignal to add a SignalPlot with a sampleRate other than 1.
public partial class MainWindow : Window
{
private SignalPlot sp;
private MarkerPlot HighlightedPoint = new();
private int LastHighlightedIndex = -1;
public MainWindow()
{
InitializeComponent();
double[] yData = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 };
WpfGraph.Plot.Clear();
sp = WpfGraph.Plot.AddSignal(yData, 2);
// Add a red circle we can move around later as a highlighted point indicator
HighlightedPoint = WpfGraph.Plot.AddPoint(0, 0);
HighlightedPoint.Color = System.Drawing.Color.Red;
HighlightedPoint.MarkerSize = 8;
HighlightedPoint.MarkerShape = MarkerShape.openCircle;
HighlightedPoint.IsVisible = false;
WpfGraph.Refresh();
WpfGraph.MouseMove += WpfGraph_MouseMove;
}
private void WpfGraph_MouseMove(object sender, MouseEventArgs e)
{
(double mouseCoordX, double mouseCoordY) = WpfGraph.GetMouseCoordinates();
(double pointX, double pointY, int pointIndex) = sp.GetPointNearestX(mouseCoordX);
//Incorrect pointIndex returned in v4.1.55 !
//Debug.WriteLine("pointIndex = {0}", pointIndex);
WpfGraph.Plot.Title("pointIndex = " + pointIndex);
// place the highlight over the point of interest
HighlightedPoint.X = pointX;
HighlightedPoint.Y = pointY;
HighlightedPoint.IsVisible = true;
// render if the highlighted point chnaged
if (LastHighlightedIndex != pointIndex) LastHighlightedIndex = pointIndex;
WpfGraph.Refresh();
}
}System Details
- ScottPlot Version: 4.1.53?
- Operating System: Windows 11
- Application Type: WPF
- .NET Version: .NET 6.0)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BUGunexpected behaviorunexpected behavior