Skip to content

Resizing automargin BarChart results in "Cannot read property 'val' of undefined" #3600

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
ghost opened this issue Mar 4, 2019 · 2 comments
Assignees
Labels
bug something broken

Comments

@ghost
Copy link

ghost commented Mar 4, 2019

Codesandbox: https://codesandbox.io/s/r3k874mr4 , in own window to resize better: https://r3k874mr4.codesandbox.io/

plotly.js-basic-dist: 1.45.0

If I shrink-resize a responsive, automargin Plotly Horizontal Bar Chart to a greater extent quickly (e.g. drag browser window to minimum size or press minimize button, if it was previously shrinked like this), I receive following error:

Chrome:
image

Firefox:
image

The graph is made responsive by the following config:

const layout = {
  yaxis: {
    automargin: true
  },
  xaxis: {
    automargin: true
  }
};

const config = {
  responsive: true
};

Currently I am using Plotly Charts in a CSS grid layout, wrapped by React (plain plotly.js-basic-dist, no react-plotly.js).

After some research, I encountered this forum thread from Jun '17, in which the solution is basically to ignore the error, because it does not have functional impact.

However, using an React Error Boundary Handler, that error completely shut down my whole application every time it occured. It did cost me 2-3 hours of debugging time to roughly determine where the error did come from, as the message is not very intuitive.

I would really appreciate to have a fix, that does not include workarounds like manually implement a resize handler or similar, because I like the simplicity of responsive:true

@antoinerg antoinerg added the bug something broken label Mar 4, 2019
@antoinerg
Copy link
Contributor

Thank you @Ford04 for clearly reporting this issue!

There is indeed a problem with the automargin routine upon resize. The issue isn't with responsive: true itself: resizing the figure with Plotly.relayout will also return an error. This can be seen in this Codepen (without React) https://codepen.io/antoinerg/full/bZwGwK

@antoinerg antoinerg changed the title Resized responsive automargin BarChart results in "Cannot read property 'val' of undefined" Resizing automargin BarChart results in "Cannot read property 'val' of undefined" Mar 4, 2019
@etpinard
Copy link
Contributor

etpinard commented Mar 4, 2019

Thanks very much for the report @Ford04

Thanks very much for the minimal codepen @antoinerg , I'll try to tackle this at the same time as #3579

@etpinard etpinard self-assigned this Mar 4, 2019
etpinard added a commit that referenced this issue Mar 4, 2019
- which happens currently in #3600
- should make debugging easier
etpinard added a commit that referenced this issue Mar 4, 2019
- which happens currently in #3600
- should make debugging easier
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

2 participants