plotly.js
plotly.js copied to clipboard
Bug/pikul standoff position
https://github.com/plotly/plotly.js/issues/6890
Breakdown of the fix:
ax._depth
is not calculated properly in the standoff
conditional:
https://github.com/plotly/plotly.js/blob/5025fbc75b636a02d16320e7b4ff054f1fe6c301/src/plots/cartesian/axes.js#L2647-L2651
Lots of positioning calculations rely on that getLabelLevelBbox()
which, bypassing the cache, is this:
function calcLabelLevelBbox(ax, cls) {
var top, bottom;
var left, right;
if(ax._selections[cls].size()) {
... // iterate over ticklabels and get their DOM properties
} else {
top = bottom = left = right = 0;
}
return { top: top, bottom: bottom, left: left, right: right, height: bottom - top, width: right - left };
}
The issue being the else
branch, where we have no ticklabels on which to loop. We shouldn't return 0
as null
- 0
is a legitimate coordinate and will fool consumers. Instead, if we accept that an empty bounding box still has a position, but with a width and height of 0, we can calculate said position (where the ticklabel would be) and return a bounding box with no width or height. That's what I do in the fix using makeLabelFns()
, and it seems to work well.
https://github.com/plotly/plotly.js/blob/236e9a37b792e507f96b4e7488927b4f25d9d7a0/src/plots/cartesian/axes.js#L2900-L2902
Let's see if these initial commits past the tests. Probably get rid of the mocks?