Tooltip payload not working in pieChart
See original GitHub issueDo you want to request a feature or report a bug?
Bug
What is the current behavior?
Tooltip doesn’t show payload’s array
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://jsfiddle.net or similar (template: http://jsfiddle.net/qbmg1567/).
- Visit the API page http://recharts.org/#/en-US/api/Tooltip, copy the payload’s example Use it for a pie chart, which I did in below fiddle http://jsfiddle.net/u172931e/
What is the expected behavior?
It should reflect the value passed in which is payload={[{ name: '05-01', value: 12, unit: 'kg' }]}
Which versions of Recharts, and which browser / OS are affected by this issue? Did this work in previous versions of Recharts?
Windows, Chrome. and latest version of Recharts
Issue Analytics
- State:
- Created 6 years ago
- Reactions:5
- Comments:5
Top Results From Across the Web
Recharts Piechart - conditionally displaying label on each ...
I have two questions: On mouse hover , I want to show the text with percentage in tooltip. how to get percentage value...
Read more >Tooltips are not displayed on Bar/Pie Chart widget on the ...
Open a dashboard with a pie chart and a bar chart. Hover over the pie chart. Notice that there are tooltips shown. Move...
Read more >recharts/recharts - Gitter
API page for tooltip mentioned about payload attribute but i am not able to get it ... does anyone have a working example...
Read more >Recharts
Quickly build your charts with decoupled, reusable React components. Reliable. Built on top of SVG elements with a lightweight dependency on D3 submodules....
Read more >recharts.Tooltip JavaScript and Node.js code examples
Tooltip (Showing top 15 results out of 315) ... render() { const {data} = this.props; return ( <PieChart width={400} height={350}> <Pie dataKey="value" ...
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
Let me explain it with more detail. Tooltip componente gets actived when you hover a part of the analytic. While inactive, it does not pass the props you would expect, this, sometimes, causes that when you hover to trigger active state, it, instead of passing the correct props, pass payload and label as undefined or [Array(0)]. To solve this, you need to use the
content
atribut and pass a react component that will recive the props from the tooltip component. After this, trigger the active state and render the values you want (sometimes is deep nested in the payload array you reicive with the props), in my case: <Tooltip payload={arrayOfCountries} content={props => { console.log(props.payload[0]?.payload?.payload); return ( <div> {props.payload[0]?.payload?.payload?.country}:{" "} {props.payload[0]?.payload?.payload?.value} </div> ); }} /> (Be sure to use some checking if exists operator like the ? or ?? or an if statement in order to access the deep nested content on the payload prop) Disclaimer: This is what i think actually happend, i may be wrong@havywu
render() { const { active } = this.props;