Fix *auto* text of zero-length bar traces - #8078
Open
william-xue wants to merge 2 commits into
Open
william-xue wants to merge 2 commits into
william-xue wants to merge 2 commits into
Conversation
A zero-length bar kept its text hidden when textposition was *auto*, while *outside* text was drawn. Only hide text for a bar with no position or for *inside* placement.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #6474.
What changes
src/traces/bar/plot.jsreturned early for every blank bar whentextpositionwas*auto*or*inside*, so a bar of zero length never drew itstext. The early return now covers*inside*placement and bars that have no position at all (null values). Text with*auto*placement falls through to the existing fit check, which finds no room inside a zero-length bar and places the text outside.*outside*text already drew for zero-length bars, so*auto*and*outside*now agree.Validation
plotly-4.1.1.min.jsfrom the CDN, loaded in headless Chrome. One page holds two figures; the.barlayer .bartextnodes come from the DOM afternewPlot.y: [0, 5, 10],textposition: 'auto',text: ['ZERO', 'FIVE', 'TEN']FIVE,TENZERO(bartext-outside,translate(96.66, 334)),FIVE,TENy: [null, 5, 10],textposition: 'auto',text: ['NULLPT', 'FIVE', 'TEN']FIVE,TENFIVE,TEN(unchanged)The right column comes from the same page with the change applied to the bundle copy.
Tests
test/jasmine/tests/bar_test.js: new case inside theA bar plotdescribe,should draw *auto* text of zero-length bars outside. It fails before the change, because noZEROnode exists, and it asserts that a null value keeps its text hidden.test/image/baselines/bar_attrs_relative.pngandtest/image/baselines/round-bar_attrs_relative.png. Both mocks hold zero-length bars withtextposition: 'auto'and text, so their baselines gain the outside label. Thetest-baselinesjob reports the diff.I did not run the karma suites locally.
The draft log follows in a second commit, since its filename needs this PR number.