Best way to display multiple data in tooltip
See original GitHub issueI would like to show a title and a description in each of my tooltips. Something like below:
{badges.map(badge => (
<FlexCol xs={4} sm={3} className="badge" key={badge.pk}>
<img
className="badge-image"
src={urljoin(MEDIA_URL, badge.imageUrl)}
alt={badge.name}
data-multiline
data-tip={badge}
data-for="badge-tooltip"
/>
<ReactTooltip
id="badge-tooltip"
getContent={({name, description}) => (
<React.Fragment>
<p>
<strong>{name}</strong>
</p>
<p>{description}</p>
</React.Fragment>
)}
/>
</FlexCol>
}
The problem is, html5 data attributes only seem to handle strings, so we cannot send arrays or objects to it. I currently cannot see any other solution than concatenating my 2 data items in data-tip, when split it within getContent, which is far from optimal.
Would it be possible to handle any data-tip-*
attribute for me to set data-tip-name
and data-tip-description
attributes, and easily reuse them from getContent ?
Issue Analytics
- State:
- Created 5 years ago
- Comments:12
Top Results From Across the Web
display multiple values for a field in Tooltip - Tableau Community
in Tooltip, a field can be displayed only if it has one value in the category selected, if multiple values, it displays as...
Read more >Best way to display multiple data in tooltip · Issue #420 - GitHub
I would like to show a title and a description in each of my tooltips. Something like below: {badges.map(badge => (
Read more >Display multiple tooltips based on maximum and minimum of ...
Background: I have a chart with a data source. This chart has a tooltip enabled so that when a user presses one of...
Read more >How to show multiple fields from data in tooltip in a multi ...
I have two jsondata objects and I want to display multiple charts in the same highchart. One of the data objects have multiple...
Read more >How can I show multiple values on a tooltip from a table?
In this example, the tooltip will show only message field value. As per your requirement, you want to display other field data in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I did something very similar but using JSON.parse and JSON.stringify so I can manage the whole element and have more flexibility.
So instead of using
const [name, description] = dataTip.split("|");
I did something likeconst obj = JSON.parse(dataTip)
Here I can access obj.name and obj.descriptionAnd when passing the values, Instead of
data-tip={
${name}|${description}}
I did:data-tip={JSON.stringify(the_object)}
Where ‘the_object’ is the element that contains a name and description attributes@mtsalenc here the solution that we came with we created a function that handle the content in a customized component for the tooltip:
in the component using the tooltip you just pass the data-tip like this:
hope it is helpful