Skip to content

Commit c325d21

Browse files
authored
support colorbar.title.text alignment (for orientation=v)
1 parent bddbb14 commit c325d21

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

src/components/colorbar/attributes.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,15 @@ module.exports = overrideAll({
226226
'Defaults to *top* when `orientation` if *v* and ',
227227
'defaults to *right* when `orientation` if *h*.',
228228
].join(' ')
229+
},
230+
align: {
231+
valType: 'enumerated',
232+
values: ['start', 'middle', 'end'],
233+
description: [
234+
'Sets the alignment of the color bar\'s title.',
235+
'Defaults to *start* when `orientation` if *v*.',
236+
'Note: This only takes affect when `orientation` is *v*.'
237+
].join(' ')
229238
}
230239
},
231240
}, 'colorbars', 'from-root');

src/components/colorbar/defaults.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,5 @@ module.exports = function colorbarDefaults(containerIn, containerOut, layout) {
133133
});
134134
Lib.coerceFont(coerce, 'title.font', dfltTitleFont);
135135
coerce('title.side', isVertical ? 'top' : 'right');
136+
coerce('title.align', isVertical ? 'start' : 'middle');
136137
};

src/components/colorbar/draw.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ function drawColorBar(g, opts, gd) {
373373
}
374374

375375
drawTitle(ax._id + 'title', {
376-
attributes: {x: x, y: y, 'text-anchor': isVertical ? 'start' : 'middle'}
376+
attributes: {x: x, y: y, 'text-anchor': isVertical ? title.align : 'middle'}
377377
});
378378
}
379379
}

0 commit comments

Comments
 (0)