Fix *auto* text of zero-length bar traces by william-xue · Pull Request #8078 · plotly/plotly.js · GitHub
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/8078_fix.md
7 changes: 6 additions & 1 deletion src/traces/bar/plot.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,10 +568,15 @@ function appendBarText(gd, plotinfo, bar, cd, i, x0, x1, y0, y1, r, overhead, op
var hasB = calcBar.hasB;
var barIsRounded = r && r - overhead > TEXTPAD;

// A null value has no bar to place text inside of or next to.
// A zero-length bar keeps a position, so `auto` text can fall through to
// the outside placement below.
var isNullBar = !isNumeric(calcBar.s1);

if (
!text ||
textPosition === 'none' ||
((calcBar.isBlank || x0 === x1 || y0 === y1) && (textPosition === 'auto' || textPosition === 'inside'))
((calcBar.isBlank || x0 === x1 || y0 === y1) && (textPosition === 'inside' || isNullBar))
) {
bar.select('text').remove();
return;
Expand Down
24 changes: 24 additions & 0 deletions test/jasmine/tests/bar_test.js
Loading