Skip to content

Commit

Permalink
resolve #1988 - 🔪 ax._boundingBox (!)
Browse files Browse the repository at this point in the history
- replace it with getLabelLevelBBox (an extension of getLabelLevelSpan),
  to compute axis margin push values. Use cache to not have to compute
  the (costly) label bounding boxes unnecessarily
- compute ax._depth during Axes.drawOne, which is the measure in px
  between axis position and outward-most part of bounding box,
  we use this for (1) multicategory label, (2) axis title and (3)
  rangeslider positioning
  • Loading branch information
etpinard committed Sep 4, 2019
1 parent 9ebbd57 commit d2650fe
Show file tree
Hide file tree
Showing 3 changed files with 148 additions and 162 deletions.
3 changes: 1 addition & 2 deletions src/components/rangeslider/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,14 @@ module.exports = function(gd) {

var gs = fullLayout._size;
var domain = axisOpts.domain;
var tickHeight = opts._tickHeight;

opts._width = gs.w * (domain[1] - domain[0]);

var x = Math.round(gs.l + (gs.w * domain[0]));

var y = Math.round(
gs.t + gs.h * (1 - axisOpts._counterDomainMin) +
tickHeight +
(axisOpts.side === 'bottom' ? axisOpts._depth : 0) +
opts._offsetShift + constants.extraPad
);

Expand Down
9 changes: 3 additions & 6 deletions src/components/rangeslider/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,14 @@ exports.makeData = function(fullLayout) {

exports.autoMarginOpts = function(gd, ax) {
var opts = ax[name];

var tickHeight = (ax.side === 'bottom' && ax._boundingBox.height) || 0;
opts._tickHeight = tickHeight;

var bottomDepth = ax.side === 'bottom' ? ax._depth : 0;
return {
x: 0,
y: oppBottom,
y: ax._counterDomainMin,
l: 0,
r: 0,
t: 0,
b: opts._height + gd._fullLayout.margin.b + tickHeight,
b: opts._height + gd._fullLayout.margin.b + bottomDepth,
pad: constants.extraPad + opts._offsetShift * 2
};
};
Loading

0 comments on commit d2650fe

Please sign in to comment.