Skip to content
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
14 changes: 10 additions & 4 deletions src/traces/pie/plot.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,16 @@ function plot(gd, cdModule) {
transform = positionTitleOutside(cd0, gs);
}

titleText.attr('transform',
strTranslate(transform.x, transform.y) +
strScale(Math.min(1, transform.scale)) +
strTranslate(transform.tx, transform.ty));
var scale = Math.min(1, transform.scale);

if(scale) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish we could reproduce this ourselves, but some of the data we have from the Word tests suggests that there's some minimum scale that won't break things. There's certainly some size that succeeds but is already useless for practical purposes so could be deleted, somewhere between 0.1 and 0.01? Ideally we'd make this configurable but maybe we can hardcode something in that range to start?

titleText.attr('transform',
strTranslate(transform.x, transform.y) +
strScale(scale) +
strTranslate(transform.tx, transform.ty));
} else {
titleText.style('display', 'none');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OIC, you prevent even setting the transform attribute when we're going to hide the text. That seems reasonable. After a little investigation it seems we DON'T delete empty slice paths, so what we're seeing from Word must be an extra automatic optimization it does to remove elements with no visible impact. I wish it extended that optimization to scaled-down text 😜

What happens if we later edit this pie, giving this slice nonzero size? Do we reuse the element - and if so do we need to clear the display: none in the if(scale) block?

}
});

// now make sure no labels overlap (at least within one pie)
Expand Down