-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Prevent negative width or height on rect #2482
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
Conversation
Prevent "Error: <rect> attribute height: A negative value is not valid." DOM errors when very small chart sizes causes `_length` calculations to go into the negatives.
Thanks very much for bringing this up! I'm not convinced your patch is the best way to fix this bug though. Would you mind sharing a reproducible example that exhibits the DOM errors you're referring to? |
@etpinard |
I've managed to make a smaller demo https://codepen.io/vdh/pen/OvpjmX |
I'm assuming what's happening here is the margins are larger than the plot area - ie |
# Conflicts: # src/plot_api/subroutines.js
I also discovered two additional places where rects are given negative widths for tiny charts (and added guards to the PR):
@etpinard @alexcjohnson |
Right. This is exactly why we're hoping to find the root cause of this problem. Instead of patching every piece of code that might write negative svg width/height, we should (at least try to) make sure |
... to do so, we'll need some sort of reproducible example in plotly.js. |
Has there been any resolution to this problem? I have been running into the same problem within react-plotly.js within my react app. Error: attribute width: A negative value is not valid. ("-50") @ plotly.js:17171 |
So are you implying that the CodePen examples I provided earlier are inadequate? Is there a better way to create an example? I apologise that I don't have the skills or familiarity with Plotly to separate |
@vdh as far as I know no one has been able to reproduce this issue using only plotly.js (i.e. no react, no react-plotly.js). This doesn't mean plotly.js isn't doing something wrong here. But it would help you pin down why theses values are negative in the first place. |
Ok. I was able to reproduce this bug in pure plotly.js. See https://codepen.io/etpinard/pen/KRjKpg?editors=0010 and open the console to see the logs. It seems to be a problem with Closing this PR and moving the discussion to #2663 |
When working with responsive container sizes for charts, I've encountered
Error: <rect> attribute height: A negative value is not valid.
DOM errors (Chrome 65.0.3325.162). Because the container area is sometimes too small for a reasonable chart, the_length
calculations sometimes go into the negatives.This PR is just a simple guard to avoid setting invalid negative values on the
rect
elements.