Skip to content

SignalXY: Only check for ascending X values between min/max render index #1771

@bernhardbreuss

Description

@bernhardbreuss

ScottPlot Version: 4.1.40

Operating System: Win 10

Application Type: WPF

Question: Describe your question here

Hi, I am implementing a fast refreshing live chart with a SignalPlotXY. As suggested in the FAQ I created a large double array and limited the visible range with MinRenderIndex and MaxRenderIndex. This works great for my use case. However, if there are already some data to show when the SignalXY is created, a argument exception Xs must only contain ascending values is thrown.

This code snippet illustrates the problem:

double[] xs = new double[1000];
double[] ys = new double[1000];
for (int i = 0; i < 100; i++)
{
    xs[i] = i;
    ys[i] = Math.Sin(i);
}
var signalXY = WpfPlot.Plot.AddSignalXY(xs, ys);
signalXY.MinRenderIndex = 0;
signalXY.MaxRenderIndex = 99;
WpfPlot.Refresh();

I totally understand that SignalXY is optimized for ascending X values and for the visible range this constraint should be still fulfilled. As I am not always able to create the chart with an empty or ascending X array I have come up with the following thoughts on this problem:

  1. As the ascending X values check is only done on assigning data, there are still possibilities to get non ascending X values (by changing the data after assigning the array). As this could be seen as inconsistent behaviour, maybe the check could be removed.
  2. Provide the possibility to define MinRenderIndex and MaxRenderIndex when creating the signal by AddSignalXY. Then the logic in the setter of SignalPlotXYGeneric.Xs could be changed to only check the range to render.
  3. Allow the user to create a derived class which is able to handle those special situations through bypassing the check. For this SignalPlotXYGeneric.Xs should be made virtual.

I am not sure what is the best suitable solution. Or is there even a better solution for this problem?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions