8000 Axes.draw w/o getBoundingClientRect + many axis automargin fixes by etpinard · Pull Request #4165 · plotly/plotly.js · GitHub
[go: up one dir, main page]

Skip to content

Axes.draw w/o getBoundingClientRect + many axis automargin fixes #4165

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

Merged
merged 15 commits into from
Sep 6, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
resolve #1988 - 🔪 ax._boundingBox (!)
- 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
commit d2650fe30a38a4997774acc3d66f97de44b0d989
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