LGSInnovations / sigplot

SigPlot provides fast interactive web-plotting for software defined radio.
https://sigplot.lgsinnovations.com
Apache License 2.0
36 stars 26 forks source link

Plot View gets set incorrectly after removing/adding Layers and changing xmin/max #14

Closed desean1625 closed 5 years ago

desean1625 commented 6 years ago

When I remove all layers and change xmin/max after I overlay a new layer the view gets set incorrectly.

I expect the view to have the whole array in view.

Using Menu -> View ->Y Axis ->expand Full Menu -> View ->X Axis ->expand Full Also doesn't set the view to what is expected. I would expect xmin to be 3 but it gets set to -1

d = document.createElement("div")
d.style = "height:500px"
b = document.querySelector("body")
b.innerText = "";
b.appendChild(d)
plot = new sigplot.Plot(d)
plot.remove_layer(0);
plot.overlay_array([1,2,3,4,5,6]);
plot.change_settings({
                xmin: 1,
                xmax: 6
            });

plot.remove_layer(0);
plot.overlay_array([3,4,5,6,7]);
plot.change_settings({
                xmin: 3,
                xmax: 7
            });
maihde commented 6 years ago

In the code example, you are calling change_settings using the xmin and xmax but the description appears to be talking about ymin and ymax.

When you call

plot.overlay_array([3,4,5,6,7]);

you are creating a line whose y-values are 3,4,5,6,7 and x-values are 0,1,2,3,4 (the default xstart is zero and xdelta is one). So if you set xmin to three and xmax to seven, then you would only see the last two points on the plot.

With the latest develop-2.0 branch and the code above, there is a issue where the x-axis is correctly displayed 3-7 but the y-axis is showing -1 to 1 (it should show 3-7).

If I change the code example to use ymin and ymax the plot does render correctly (i.e. the x-axis is 0-4 and the y-axis is 3-7).

maihde commented 6 years ago

Please see github-issue-3 branch where I've incorporated this into a unittest and fixed the issue. Let me know if this fix resolves your issue.

jrmims commented 5 years ago

Is it safe to close this issue?