Skip to content

Plotly relayout issue when changing height on histograms #2020

Description

@popepay

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

Activity

  1. rreusser commented on Sep 19, 2017

    @rreusser
    Contributor

    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.)

  2. rreusser commented on Sep 19, 2017

    @rreusser
    Contributor

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

  3. popepay commented on Sep 19, 2017

    @popepay
    Author

    @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)

  4. rreusser commented on Sep 19, 2017

    @rreusser
    Contributor

    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.

  5. rreusser commented on Sep 19, 2017

    @rreusser
    Contributor

    @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.

  6. self-assigned this
    on Sep 20, 2017
  7. added a commit that references this issue on Sep 20, 2017
    8d9feaf
  8. popepay commented on Sep 20, 2017

    @popepay
    Author

    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!

  9. etpinard commented on Sep 20, 2017

    @etpinard
    Contributor

    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

Metadata

Metadata

Assignees

Labels

bugsomething broken

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions