ScottPlot: DataLogger ViewSlide() does not work as expected when using right axes

Issue: When I add a right Axis to my plot the DataLogger.ViewSlide() stops working as expected.

ScottPlot Version: 5.0.25

Code Sample: To reproduce, I added the last 2 lines in your demo datalogger file

Logger = formsPlot1.Plot.Add.DataLogger();

var axis = formsPlot1.Plot.Axes.AddRightAxis();
Logger.Axes.YAxis = axis;

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 24 (24 by maintainers)

Commits related to this issue

Most upvoted comments

Hi @jpgarza93, thanks for reporting this! I think it has been fixed in #3641 and will be working better in the next release (5.0.56). If not, let me know and we can re-open this issue and take a closer look 👍

@swharden thank you for your dedication, time, and tireless efforts!

Got it! Thanks for your persistence @jpgarza93. This should be fixed in the next release 🚀 https://github.com/ScottPlot/ScottPlot/commit/d0796fa13be2779267d75ad055a50640aa3bab43

Here’s an even simpler reproducible example. It confirms the issue is not related to the datalogger.

Resizing the window makes the left axis appear.

public DataLogger()
{
    InitializeComponent();

    var sig = formsPlot1.Plot.Add.Signal(Generate.Sin());
    sig.Axes.YAxis = formsPlot1.Plot.Axes.Right;
}

Tested it with a data logger and it works the same 👍

using ScottPlot;

namespace WinForms_Demo.Demos;
public partial class DataStreamer : Form, IDemoWindow
{
    public string Title => "Data Streamer";
    public string Description => "Plots live streaming data as a fixed-width line plot, " +
        "shifting old data out as new data comes in.";

    readonly System.Windows.Forms.Timer AddNewDataTimer = new() { Interval = 10, Enabled = true };
    readonly System.Windows.Forms.Timer UpdatePlotTimer = new() { Interval = 50, Enabled = true };

    readonly ScottPlot.Plottables.DataLogger Logger1;
    readonly ScottPlot.Plottables.DataLogger Logger2;

    readonly ScottPlot.DataGenerators.RandomWalker Data1 = new();
    readonly ScottPlot.DataGenerators.RandomWalker Data2 = new();

    public DataStreamer()
    {
        InitializeComponent();

        // add a streamers to the plot
        Logger1 = formsPlot1.Plot.Add.DataLogger();
        Logger2 = formsPlot1.Plot.Add.DataLogger();

        // identify the axes to use
        IYAxis yAxisRight1 = formsPlot1.Plot.Axes.Right;
        IYAxis yAxisRight2 = formsPlot1.Plot.Axes.AddRightAxis();

        // set axis colors to match the data streamers they display
        formsPlot1.Plot.Axes.Color(yAxisRight1, Logger1.Color);
        formsPlot1.Plot.Axes.Color(yAxisRight2, Logger2.Color);

        // wire streamers to axes
        Logger1.Axes.YAxis = yAxisRight1;
        Logger2.Axes.YAxis = yAxisRight2;

        // setup a timer to add data to the streamer periodically
        AddNewDataTimer.Tick += (s, e) =>
        {
            Logger1.Add(Data1.Next(10));
            Logger2.Add(Data2.Next(10));
        };

        // setup a timer to request a render periodically
        UpdatePlotTimer.Tick += (s, e) =>
        {
            if (Logger1.HasNewData || Logger2.HasNewData)
            {
                formsPlot1.Refresh();
            }
        };
    }
}

Hello @swharden, are you suggesting I use datastreamer instead of datalogger?

Oh, sorry 😅 I was addressing another issue today that involved the streamer and I mixed-up the use case

I’m pretty sure the concept will be the same for data loggers… I’ll see if I can adapt that demo to test it now

Ah, gotcha. It sounds like you’re using multiple dataloggers. Thanks for the clarification! I’ll modify the demo app to test this and follow-up shortly 👍

Thanks for the tip! I’ll look into it now 👍 3637