Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions draftlogs/7509_add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add `align` attribute to `colorbar.title` to control the alignment of the title [[#7509](https://github.com/plotly/plotly.js/pull/7509)]
9 changes: 9 additions & 0 deletions src/components/colorbar/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,15 @@ module.exports = overrideAll({
'Defaults to *top* when `orientation` if *v* and ',
'defaults to *right* when `orientation` if *h*.',
].join(' ')
},
align: {
valType: 'enumerated',
values: ['start', 'middle', 'end'],
description: [
'Sets the alignment of the color bar\'s title.',
'Defaults to *start* when `orientation` if *v*.',
'Note: This only takes affect when `orientation` is *v*.'
].join(' ')
}
},
}, 'colorbars', 'from-root');
1 change: 1 addition & 0 deletions src/components/colorbar/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,5 @@ module.exports = function colorbarDefaults(containerIn, containerOut, layout) {
});
Lib.coerceFont(coerce, 'title.font', dfltTitleFont);
coerce('title.side', isVertical ? 'top' : 'right');
coerce('title.align', isVertical ? 'start' : 'middle');
};
2 changes: 1 addition & 1 deletion src/components/colorbar/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ function drawColorBar(g, opts, gd) {
}

drawTitle(ax._id + 'title', {
attributes: {x: x, y: y, 'text-anchor': isVertical ? 'start' : 'middle'}
attributes: {x: x, y: y, 'text-anchor': isVertical ? title.align : 'middle'}
});
}
}
Expand Down
Loading