-
Notifications
You must be signed in to change notification settings - Fork 981
Description
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:
- 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.
- Provide the possibility to define
MinRenderIndexandMaxRenderIndexwhen creating the signal byAddSignalXY. Then the logic in the setter ofSignalPlotXYGeneric.Xscould be changed to only check the range to render. - Allow the user to create a derived class which is able to handle those special situations through bypassing the check. For this
SignalPlotXYGeneric.Xsshould be made virtual.
I am not sure what is the best suitable solution. Or is there even a better solution for this problem?