Skip to content

Commit 2e0440f

Browse files
committed
fix centering multi-line headers in treemap
1 parent 39bd75f commit 2e0440f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/traces/treemap/draw_descendants.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,13 @@ module.exports = function drawDescendants(gd, cd, entry, slices, opts) {
184184

185185
var font = Lib.ensureUniformFontSize(gd, helpers.determineTextFont(trace, pt, fullLayout.font));
186186

187-
sliceText.text(pt._text || ' ') // use one space character instead of a blank string to avoid jumps during transition
187+
188+
var text = pt._text || ' '; // use one space character instead of a blank string to avoid jumps during transition
189+
var singleLineHeader = isHeader && text.indexOf('<br>') === -1;
190+
191+
sliceText.text(text)
188192
.classed('slicetext', true)
189-
.attr('text-anchor', hasRight ? 'end' : (hasLeft || isHeader) ? 'start' : 'middle')
193+
.attr('text-anchor', hasRight ? 'end' : (hasLeft || singleLineHeader) ? 'start' : 'middle')
190194
.call(Drawing.font, font)
191195
.call(svgTextUtils.convertToTspans, gd);
192196

0 commit comments

Comments
 (0)