Skip to content

Fix centering multi-line headers for treemap traces #6923

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 3 commits into from
Mar 15, 2024
Merged
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
Next Next commit
fix centering multi-line headers in treemap
  • Loading branch information
archmoj committed Mar 14, 2024
commit 2e0440fe0daf841b3921ad2eebdc4126470a9a3a
8 changes: 6 additions & 2 deletions src/traces/treemap/draw_descendants.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,13 @@ module.exports = function drawDescendants(gd, cd, entry, slices, opts) {

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

sliceText.text(pt._text || ' ') // use one space character instead of a blank string to avoid jumps during transition

var text = pt._text || ' '; // use one space character instead of a blank string to avoid jumps during transition
var singleLineHeader = isHeader && text.indexOf('<br>') === -1;

sliceText.text(text)
.classed('slicetext', true)
.attr('text-anchor', hasRight ? 'end' : (hasLeft || isHeader) ? 'start' : 'middle')
.attr('text-anchor', hasRight ? 'end' : (hasLeft || singleLineHeader) ? 'start' : 'middle')
.call(Drawing.font, font)
.call(svgTextUtils.convertToTspans, gd);

Expand Down