Skip to content

Plotly relayout issue when changing height on histograms #2020

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

Closed
popepay opened this issue Sep 19, 2017 · 7 comments
Closed

Plotly relayout issue when changing height on histograms #2020

popepay opened this issue Sep 19, 2017 · 7 comments
Assignees
Labels
bug something broken

Comments

@popepay
Copy link

popepay commented Sep 19, 2017

Hello,

I noticed a strange issue when changing the height of that particular plot.

Link to example (working & non-working):
https://codepen.io/cariacou/pen/VMapvo

Source of the error seems to be that pos0 is undefined

Thanks to @rreusser for helping me through the bug reporting. Now the post should be a lot more readable.
I have updated this post with the work he did in order to have all the information in one place

@rreusser
Copy link
Contributor

rreusser commented Sep 19, 2017

It's a bit difficult to understand the problem. I've cleaned up your input for readability, but could you fork and modify this codepen to demonstrate the issue? Thanks! https://codepen.io/rsreusser/pen/ZXWLxy?editors=1010

(Also, plotly-latest.min.js is effectively useless for stack traces. plotly-latest.js is much more helpful.)

@rreusser
Copy link
Contributor

rreusser commented Sep 19, 2017

Ah, thanks for cleaning up the issue a bit! I can now reproduce the issue here: https://codepen.io/rsreusser/pen/ZXWLxy?editors=1010

@popepay
Copy link
Author

popepay commented Sep 19, 2017

@rreusser Thank you for the very prompt response!

I have updated the Original Post with a working example (which is identical to the non-working but has the 2nd trace removed)

@rreusser
Copy link
Contributor

rreusser commented Sep 19, 2017

No problem. Here's a much more minimal reproduction that shows the same issue:

Plotly.plot('graph', [{
  "type": "histogram",
  "x": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],
 }, {
  "type": "histogram",
  "x": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],
}]).then(function () {
  return Plotly.relayout('graph', {width: 500});
});

Stack trace:

plotly-latest.js:168259 Uncaught (in promise) TypeError: Cannot read property 'length' of undefined
    at Object.calc (plotly-latest.js:168259)
    at Object.plots.doCalcdata (plotly-latest.js:152035)
    at Object.Plotly.plot (plotly-latest.js:130164)
    at Object.plots.doAutoMargin (plotly-latest.js:151326)
    at Object.plots.supplyDefaults (plotly-latest.js:150322)
    at Object.Plotly.plot (plotly-latest.js:130133)
    at exports.layoutReplot (plotly-latest.js:134268)
    at Object.lib.syncOrAsync (plotly-latest.js:126168)
    at Object.relayout (plotly-latest.js:131883)
    at pen.js:8

The issue seems to be with the lines:

    var nMax = size.length;
    // bin the data
    for(i = 0; i < pos0.length; i++) {
        n = Lib.findBin(pos0[i], bins);
        if(n >= 0 && n < nMax) total += binFunc(n, i, size, rawCounterData, counts);
    }

Though I'm having trouble figuring out exactly what the problem is via the chrome debugger alone. Seems to happen only when two histogram traces are present, not just one. Thoughts, @alexcjohnson?

Source of the error seems like this neighborhood in histogram/calc.js.

@rreusser
Copy link
Contributor

rreusser commented Sep 19, 2017

@popepay The cause isn't 100% clear yet, but hopefully it's at least fairly easy to solve at this point. Thanks for helping clarify! Definitely seems like something's not quite right though. Probably won't get resolved in the next couple hours, but hopefully should be able to get it fixed pretty quickly and released pretty soon.

@rreusser rreusser added the bug something broken label Sep 19, 2017
@alexcjohnson alexcjohnson self-assigned this Sep 20, 2017
@popepay
Copy link
Author

popepay commented Sep 20, 2017

Is there anything I should do to update https://cdn.plot.ly/plotly-latest.js / plotly-min.js ?
Or will someone take care of this?

thanks again for finding the glitch!

@etpinard
Copy link
Contributor

etpinard commented Sep 20, 2017

Is there anything I should do to update https://cdn.plot.ly/plotly-latest.js / plotly-min.js ?

Wait until v1.31.0 is out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

No branches or pull requests

4 participants