Skip to content
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

Makes auto-margin step dependent on axis label span #312

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
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
14 changes: 14 additions & 0 deletions src/plots/cartesian/axes.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ var d3 = require('d3');
var isNumeric = require('fast-isnumeric');

var Plotly = require('../../plotly');
var Plots = require('../../plots/plots');
var Titles = require('../../components/titles');

var axes = module.exports = {};
Expand Down Expand Up @@ -1492,6 +1493,19 @@ axes.doTicks = function(td, axid, skipTitle) {
d.font, d.fontSize, d.fontColor)
.text(d.text)
.call(Plotly.util.convertToTspans);

var bb = Plotly.Drawing.bBox(thisLabel.node());
var horizontalShift = ax.l2p(d.x)/fullLayout.width/2;
var verticalShift = (bb.height + bb.bottom + bb.top) / fullLayout.height;
Plots.autoMargin(td,'axis'+axid,{
x: -horizontalShift,
y: -verticalShift,
l: 0,
r: 0,
b: 0,
t: 0
});

newPromise = td._promises[newPromise];
if(newPromise) {
// if we have an async label, we'll deal with that
Expand Down