question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Tooltip text not working when text is 0 (number)

See original GitHub issue

Example that displays the error

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. image

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.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
dallecommented, May 30, 2018

@alexcjohnson Did I create the PR correctly?

1reaction
alexcjohnsoncommented, 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. https://github.com/plotly/plotly.js/blob/dfb56d3a7b99ecf979365ed9b9c2c40747cdd915/src/traces/scatter/fill_hover_text.js#L38-L41 @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:

mode: 'lines+markers+text',
textposition: 'top right'

and you’ll see the zeros get left out there too: screen shot 2018-05-24 at 9 09 47 am

Read more comments on GitHub >

github_iconTop Results From Across the Web

Text disappears when I add the tooltip class - html
Press the Run code snippet in the answer. This is working. If you're not seeing the tooltip, it must be something else in...
Read more >
Tooltips · Bootstrap v5.0
Tooltips with zero-length titles are never displayed. Specify container: 'body' to avoid rendering problems in more complex components (like our input groups, ...
Read more >
Tooltip
A simple text popup tip. When To Use. The tip is shown on mouse enter, and is hidden on mouse leave. The Tooltip...
Read more >
How to customize tooltips
Emphasize text with HTML; Create a mini-table; Add extra information about certain regions; Add two numbers together; Change the number ...
Read more >
Tooltips | Charts
The previous examples have all used tooltips with plain text content, but the real power ... Note: this does not work with the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found