You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Tooltip text not working when text is 0 (number) #2660
I want to be able to get a value from the text property in the data object. I noticed that if the value is the number 0 it won't be displayed in the plot.
text: [0,0,0,0,0],hoverinfo: "x+text+name",
The code above will make the tooltip only show x and name. The text property won't be visible.
All other values except 0 will render properly, as can be seen in the code example linked above. Also if all the numbers are strings they will be shown correctly.
I guess that there is a null-check somewhere that treats 0 as false and therefore won't add it to the tooltip.
@dalle Looks likely that's the culprit - any chance you'd like to make a PR combining those two diffs with a test covering both parts? Perhaps based on:
but I could not understand how to test for the marker.
Once you've made a plot that has text on the markers (which is done in the beforeEach block in the linked test) you should just be able to do something like:
d3.select(gd).selectAll('.textpoint text').size()
to check that the correct number of text markers are created - in the codesandbox example above, the .textpoint groups are empty in the bug case.
Activity
dalle commentedon May 24, 2018
I think this will fix it:
alexcjohnson commentedon May 24, 2018
Thanks @stillesjo ! Interestingly we have a comment implying that we had addressed exactly this issue, so we'll have to look at it.
plotly.js/src/traces/scatter/fill_hover_text.js
Lines 38 to 41 in dfb56d3
@dalle thanks, that would fix a related bug - display of the text alongside the markers. Add this to each of the traces in @stillesjo's example:
and you'll see the zeros get left out there too:

dalle commentedon May 25, 2018
Okay, one more try:
alexcjohnson commentedon May 25, 2018
@dalle Looks likely that's the culprit - any chance you'd like to make a PR combining those two diffs with a test covering both parts? Perhaps based on:
plotly.js/test/jasmine/tests/hover_label_test.js
Line 105 in 887cae6
dalle commentedon May 28, 2018
@alexcjohnson Creating a new hover label test seems easy, but I could not understand how to test for the marker.
alexcjohnson commentedon May 29, 2018
Ah great, that's the harder test!
Once you've made a plot that has text on the markers (which is done in the
beforeEachblock in the linked test) you should just be able to do something like:to check that the correct number of text markers are created - in the codesandbox example above, the
.textpointgroups are empty in the bug case.treat zero as valid fixes plotly#2660
dalle commentedon May 30, 2018
@alexcjohnson Did I create the PR correctly?
Fix for number 0 treated as invalid in hover (#1)