`autorange` throws when y range is small
Open
Nobody has claimed this yet.
bug
P2
- Dominant language
- JavaScript
- Stars
- 18.3k
- Forks
- 2k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 28
Description
When max(y) - min(y) is a very small value, ie, Number.MIN_VALUE, plotly failed to draw the plot.
Codepen https://codepen.io/opportunityliu/pen/QWmwPEO
TESTER = document.getElementById('tester');
Plotly.react( TESTER, [{
x: [1, 2, 3, 4, 5],
y: [0,0,0,0,Number.MIN_VALUE] }]);

Got error:
plotly-2.12.1.js:141901
Uncaught TypeError: Cannot read properties of undefined (reading 'val')
at getAutoRange (plotly-2.12.1.js:141901:26)
at doAutoRange (plotly-2.12.1.js:142098:56)
at exports.doAutoRangeAndConstraints (plotly-2.12.1.js:140196:13)
at doAutoRangeAndConstraints (plotly-2.12.1.js:134769:21)
at lib.syncOrAsync (plotly-2.12.1.js:129221:15)
at positionAndAutorange (plotly-2.12.1.js:134759:20)
at lib.syncOrAsync (plotly-2.12.1.js:129221:15)
at Object._doPlot (plotly-2.12.1.js:134834:24)
at Object.newPlot (plotly-2.12.1.js:135011:20)
at Object.react (plotly-2.12.1.js:137070:28)
When the diff become slightly larger, ie, 1e-310, I got another error and an empty plot
Codepen https://codepen.io/opportunityliu/pen/wvmBZEy
TESTER = document.getElementById('tester');
Plotly.react( TESTER, [{
x: [1, 2, 3, 4, 5],
y: [0,0,0,0,1e-310] }]);

plotly-2.12.1.js:153093
Uncaught Error: Something went wrong with axis scaling
at ax.setScale (plotly-2.12.1.js:153093:19)
at axes.drawOne (plotly-2.12.1.js:144647:8)
at plotly-2.12.1.js:144605:31
at lib.syncOrAsync (plotly-2.12.1.js:129221:15)
at axes.draw (plotly-2.12.1.js:144600:16)
at drawAxes (plotly-2.12.1.js:134783:21)
at lib.syncOrAsync (plotly-2.12.1.js:129221:15)
at Object._doPlot (plotly-2.12.1.js:134834:24)
at Object.newPlot (plotly-2.12.1.js:135011:20)
at Object.react (plotly-2.12.1.js:137070:28)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure with the two JavaScript examples and trace the reported stack from getAutoRange and doAutoRange to ax.setScale. The fix is done when both very-small y ranges render successfully without the undefined-value or axis-scaling errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100