ScottPlot icon indicating copy to clipboard operation
ScottPlot copied to clipboard

LockedVerticalRule combined with SignalXY causes jank when panning

Open ronnyek opened this issue 9 months ago • 4 comments

Issue: (Describe the bug here) I applied LockedVerticalRule to each subplot in the MultiPlotDraggable Subplots demo in the avalonia samples. When doing so, the candlestick and barchart behave exactly as expected, but with the Signal/SignalXY, I get jank. The line rendered will jump around dragging within the normal constraints,

ScottPlot Version: (What NuGet package are you using?) Happens in 5.0.55 and master in the latest clone I've done of this repo

Code Sample:

Where there is a loop in the MultiPlotDraggableWindow.cs file, I literally modified the loop to apply vertical rules like this to every subplot.

foreach (Plot plot in AvaPlot.Multiplot.GetPlots())
{
    plot.Axes.Left.LockSize(10);
    plot.Axes.Right.LockSize(80);
    
    var axisLimits = plot.Axes.GetLimits(plot.Axes.Bottom, plot.Axes.Right);
    LockedVertical lockedVertical = new (plot.Axes.Right, axisLimits.YRange.Min,axisLimits.YRange.Max);
    volumePlot.Axes.Rules.Add(lockedVertical);
    volumePlot.Axes.AutoScale();
}

Image

ronnyek avatar Apr 01 '25 21:04 ronnyek

Actually looking at the code, I'm not sure how that code works as well as it does, since those subplots all use the volume plot xAxis. If I actually apply the rules per plot (not getting limits for each chart, but seemingly applying the rules all to the volumeplot xaxis), it does even less predictable things. bar chart plot visible, the rest aren't.

If I simply apply the rule to volume plot all by itself bar chart gets the jank and the other two charts pan around as expected.

What would be the right approach here? I like exactly how this demo works (all my subplots would be signal or signalxy), except

  1. Not be able to pan beyond the beginning or end of the data, or zoom in/out to unreasonable levels... (most zoomed out showing all datapoints and no further
  2. scale changes affect the charts like the animated gif... (data series is always visible for the span min/max
  3. Preferrably no jank/jitter

ronnyek avatar Apr 02 '25 14:04 ronnyek

It seems like while the rules might enforce limits at draw time, it seems like it doesn't block axis changes from being communicated to other charts with the same shared x axis. You can see when I vertically drag the volume chart up and down, the bars down move up and down, but you can see the ticks on right axis getting redrawn (numbers change and move). Other charts that are not constrained also move.

ronnyek avatar Apr 02 '25 17:04 ronnyek

Disabling vertical panning in UserInputManager definitely helped with the vertical panning... and I did notice one other thing... I think there is a problem with the rules when dealing with charts of a different type. if they are all line charts (signal) I think I can get what I want working now... but I think because candlestick and bar charts have a certain width to data points (not just a point) the boundaries arent the same with shared axis. Seemed like een fully zoomed out you could drag one subplot and have it scroll others a couple pixels left/right. (I dont see this with 3 signals)

ronnyek avatar Apr 02 '25 18:04 ronnyek