Skip to content

Fix axis line width, length, and positioning for coupled subplots #1854

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 13 commits into from
Jul 14, 2017
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
10 changes: 9 additions & 1 deletion src/constants/alignment.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,13 @@ module.exports = {
top: 0
},
// multiple of fontSize to get the vertical offset between lines
LINE_SPACING: 1.3
LINE_SPACING: 1.3,

// multiple of fontSize to shift from the baseline to the midline
// (to use when we don't calculate this shift from Drawing.bBox)
// To be precise this should be half the cap height (capital letter)
// of the font, and according to wikipedia:
// an "average" font might have a cap height of 70% of the em
// https://en.wikipedia.org/wiki/Em_(typography)#History
MID_SHIFT: 0.35
};
4 changes: 3 additions & 1 deletion src/plots/cartesian/axes.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ var ONEHOUR = constants.ONEHOUR;
var ONEMIN = constants.ONEMIN;
var ONESEC = constants.ONESEC;

var MID_SHIFT = require('../../constants/alignment').MID_SHIFT;

var axes = module.exports = {};

axes.layoutAttributes = require('./layout_attributes');
Expand Down Expand Up @@ -1796,7 +1798,7 @@ axes.doTicks = function(gd, axid, skipTitle) {
else {
flipit = (axside === 'right') ? 1 : -1;
labely = function(d) {
return d.dy + d.fontSize * 0.35 - labelShift * flipit;
return d.dy + d.fontSize * MID_SHIFT - labelShift * flipit;
};
labelx = function(d) {
return d.dx + position + (labelStandoff + pad +
Expand Down
3 changes: 2 additions & 1 deletion src/plots/polar/micropolar.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
var d3 = require('d3');
var Lib = require('../../lib');
var extendDeepAll = Lib.extendDeepAll;
var MID_SHIFT = require('../../constants/alignment').MID_SHIFT;

var µ = module.exports = { version: '0.2.2' };

Expand Down Expand Up @@ -295,7 +296,7 @@ var µ = module.exports = { version: '0.2.2' };
angularAxisEnter.append('text').classed('axis-text', true).style(fontStyle);
var ticksText = angularAxis.select('text.axis-text').attr({
x: radius + axisConfig.labelOffset,
dy: '.35em',
dy: MID_SHIFT + 'em',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🏆 for patching the polar code.

transform: function(d, i) {
var angle = currentAngle(d, i);
var rad = radius + axisConfig.labelOffset;
Expand Down