Skip to content

SignalXY: Fix final segment is not being rendered#3495

Merged
swharden merged 4 commits intoScottPlot:mainfrom
MareMare:fix/3423
Mar 19, 2024
Merged

SignalXY: Fix final segment is not being rendered#3495
swharden merged 4 commits intoScottPlot:mainfrom
MareMare:fix/3423

Conversation

@MareMare
Copy link
Contributor

This will fix issue #3423

test code:
using ScottPlot;

namespace Sandbox5;

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
        Size = new Size(800, 450);
        Text = "ScottPlot5-WinForms for Issue 3423";

        var line = formsPlot1.Plot.Add.Line(0, 0, 1, 0);
        line.Label = "SP5:Line";
        line.LineWidth = 5;

        var signal = formsPlot1.Plot.Add.Signal(new double[] { 1, 1 });
        signal.Label = "SP5:Signal";
        signal.LineWidth = 5;

        // SignalXYSourceDoubleArray
        double[] xs1 = Generate.Consecutive(3);
        double[] ys1 = Generate.Repeating(3, 2);
        var signalXY1 = formsPlot1.Plot.Add.SignalXY(xs1, ys1);
        signalXY1.Label = "SP5:SignalXY";
        signalXY1.LineWidth = 5;

        // SignalXYSourceGenericArray
        float[] xs2 = Generate.Consecutive(3).Select(value => (float)value).ToArray();
        int[] ys2 = Generate.Repeating(3, 3).Select(value => (int)value).ToArray();
        var signalXY2 = formsPlot1.Plot.Add.SignalXY(xs2, ys2);
        signalXY2.Label = "SP5:SignalXY Generic";
        signalXY2.LineWidth = 5;

        formsPlot1.Plot.ShowLegend();
        formsPlot1.Plot.HideGrid();
        formsPlot1.Refresh();
    }
}

image

Changes were made to mimic the way conditions were determined in SP4.
Also, the GetIndex method is now public in SP5, so we left it as is.

@MareMare MareMare marked this pull request as draft March 17, 2024 04:30
@MareMare MareMare marked this pull request as ready for review March 17, 2024 05:21
@MareMare
Copy link
Contributor Author

Vertical SignalXY with Inverted X Axis:
using ScottPlot;

namespace Sandbox5;

public partial class Form2 : Form
{
    public Form2()
    {
        InitializeComponent();
        Size = new Size(800, 450);
        Text = "ScottPlot5-WinForms for Issue 3423";

        // SignalXYSourceDoubleArray Rotated
        double[] xs3 = Generate.Consecutive(3);
        double[] ys3 = Generate.Repeating(3, 4);
        var signalXY3 = formsPlot1.Plot.Add.SignalXY(xs3, ys3);
        signalXY3.Data.Rotated = true;
        signalXY3.Label = "SP5:SignalXY Rotated with Inverted X Axis";
        signalXY3.LineWidth = 5;

        formsPlot1.Plot.Axes.SetLimitsX(8.1, -0.1);
        formsPlot1.Plot.ShowLegend();
        formsPlot1.Plot.HideGrid();
        formsPlot1.Refresh();
    }
}

image

Vertical SignalXY with Inverted Y Axis:
using ScottPlot;

namespace Sandbox5;

public partial class Form3 : Form
{
    public Form3()
    {
        InitializeComponent();
        Size = new Size(800, 450);
        Text = "ScottPlot5-WinForms for Issue 3423";

        // SignalXYSourceDoubleArray Rotated
        double[] xs3 = Generate.Consecutive(3);
        double[] ys3 = Generate.Repeating(3, 4);
        var signalXY3 = formsPlot1.Plot.Add.SignalXY(xs3, ys3);
        signalXY3.Data.Rotated = true;
        signalXY3.Label = "SP5:SignalXY Rotated with Inverted Y Axis";
        signalXY3.LineWidth = 5;

        formsPlot1.Plot.Axes.SetLimitsY(2.1, -0.1);
        formsPlot1.Plot.ShowLegend();
        formsPlot1.Plot.HideGrid();
        formsPlot1.Refresh();
    }
}

image

@swharden swharden linked an issue Mar 19, 2024 that may be closed by this pull request
@swharden
Copy link
Member

This is fantastic @MareMare, thanks for your quick work on this one! 🚀

@swharden swharden enabled auto-merge March 19, 2024 01:42
@swharden swharden merged commit f1b6ed2 into ScottPlot:main Mar 19, 2024
@MareMare
Copy link
Contributor Author

Thank you for your time!
Thank you also for taking the time to read my poor English😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SignalXY: final segment is not being rendered

2 participants