Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Y Axis undefined (fatal error) if all series on axis are hidden. #191

Open
BubbleupHosting opened this issue Oct 4, 2019 · 1 comment
Open

Comments

@BubbleupHosting
Copy link

When instantiating a line graph with multiple series on multiple y-axes, if a particular axis has only series with {show: false} it will die with a fatal error:

jQuery.Deferred exception: yp is undefined $.jqplot.LineRenderer.prototype.setGridData@http://atlas.bubbleupsandbox.ca/jqplot/jquery.jqplot.js:5584:71

This error is slightly different but less helpful when using minified JQPlot.

An axis is undefined if all series assigned to it are set to {show: false} and therefore instead of just hiding the axis or plotting nothing. The undefined value causes a fatal error and JS kicks out without rendering the rest of the lines or applying other plugins that might be enabled.
Here is a simple example of code to reproduce the issue:

let plot1 = jQuery.jqplot( 'chart1', [ [ [1, 578], [2, 566], [3, 480], [4, 509], [5, 454], [6, 379], [7, 303], [8, 308], [9, 299], [10, 346], [11, 325], [12, 386] ], [ [1, 428], [2, 466], [3, 390], [4, 419], [5, 374], [6, 309], [7, 233], [8, 228], [9, 189], [10, 236], [11, 205], [12, 256] ], [ [1, 248], [2, 336], [3, 250], [4, 279], [5, 254], [6, 179], [7, 153], [8, 108], [9, 99], [10, 146], [11, 125], [12, 186] ], [ [1, 678], [2, 666], [3, 580], [4, 609], [5, 564], [6, 469], [7, 503], [8, 438], [9, 389], [10, 466], [11, 475], [12, 456] ], ], { title:'Broken Axes', axes: { xaxis: { label: 'X-Axis', }, yaxis: { label : 'First Y-Axis', }, y2axis: { label : 'Second Y-Axis', }, }, series: [ { show: true, color: 'red', yaxis: 'yaxis', }, { show: false, color: 'blue', yaxis: 'y2axis', }, { show: false, color: 'purple', yaxis: 'y2axis', }, { show: true, color: 'orange', yaxis: 'yaxis', }, ], } );

Also at this JS Fiddle: http://jsfiddle.net/L4juxvd3/3/

When series 2 and 3 (both on y2axis) are both hidden, the final orange series (on yaxis) never gets to render because of the error.

A workaround is to render the graph and then manually hide each series that shouldn't be there and re-plot the graph, but that should not be necessary, especially as {show: false} is a basic property built right into Series which simply breaks whole graphs.

@BubbleupHosting
Copy link
Author

Adding {scaleToHiddenSeries: true} to axes which have only hidden series is a workaround, but it means that if series on a single axis have rather different scales (~10 vs ~50) can produce a lot of empty space if only one is shown.

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

No branches or pull requests

1 participant