Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b682fe3

Browse files
committed
Vertically center multi-line labels on Y axis.
1 parent bb90e1d commit b682fe3

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/plots/cartesian/axes.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ var MINUS_SIGN = constants.MINUS_SIGN;
3131
var BADNUM = constants.BADNUM;
3232

3333
var MID_SHIFT = require('../../constants/alignment').MID_SHIFT;
34+
var LINE_SPACING = require('../../constants/alignment').LINE_SPACING;
3435

3536
var axes = module.exports = {};
3637

@@ -1869,7 +1870,9 @@ axes.doTicks = function(gd, axid, skipTitle) {
18691870
else if(axLetter === 'y') {
18701871
sides = ['left', 'right'];
18711872
transfn = ax._transfn || function(d) {
1872-
return 'translate(0,' + (ax._offset + ax.l2p(d.x)) + ')';
1873+
var multilineCorrection = d.text ?
1874+
-0.5 * (d.text.split('<br>').length - 1) * LINE_SPACING * d.fontSize : 0;
1875+
return 'translate(0,' + (ax._offset + ax.l2p(d.x) + multilineCorrection) + ')';
18731876
};
18741877
tickpathfn = function(shift, len) {
18751878
if(ax._counterangle) {
-14 Bytes
Loading

0 commit comments

Comments
 (0)