ComposedChart w/ different tooltips per datasets
See original GitHub issueDo you want to request a feature or report a bug?
report a bug
What is the current behavior?
Currently if using a ComposedChart w/ multiple datasets the tooltip only renders one data set on hover. (IE rendering a Bar w/ 1 data set, and overlaying with a Line w/ a different dataset when hovering over any axis point the tooltip will only show the lines payload.)
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/ndLhnegs/).
Example code
<ResponsiveContainer height={'100%'} width={'100%'}>
<ComposedChart
height={400}
data={data.plot}
barGap={2}
>
<CartesianGrid
stroke="#f5f5f5"
strokeDasharray="0"
vertical={false}
/>
<XAxis
dataKey="label"
tickSize={0}
tickMargin={8}
/>
<YAxis
orientation="right"
tickFormatter={formatter}
width={100}
tickSize={0}
tickMargin={8}
axisLine={false}
domain={[0, maxValue]}
/>
<Tooltip content={<CustomTooltip/>}/>
<Bar
dataKey="foo"
barSize={105}
fill="#003349"
formatter={formatter}
radius={[2, 2, 0, 0]}
/>
<Line name="Selected Period" type="monotone" data={data['2018'].plot} dataKey="bar" />
</ComposedChart>
</ResponsiveContainer>
What is the expected behavior?
I would expect if you hover over the Bar or Line the tooltip would show that payload.
Which versions of Recharts, and which browser / OS are affected by this issue? Did this work in previous versions of Recharts?
recharts v1.5.0
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
How to Show Different Data in Tooltip Based on ... - YouTube
Sometimes you want to show different data in the tooltip per dataset. This is possible with some tiny customizations.
Read more >How to Customize Each Tooltip Dataset in Chart JS - YouTube
... tooltip dataset in chart js. With Chart.js we can customize the tooltip. ... It requires a lot of different moving parts to...
Read more >Recharts - How to have two different tooltips for Line and Bar ...
The idea here is to maintain a state of chart for which you want to show the tooltip. Then update the state onMouseOver...
Read more >Graphing, React-ing, and maybe a little crying | Mux blog
Unlike the two previous tools, Recharts doesn't allow you to provide a dataset to each chart component in a composed chart. What we...
Read more >Build and Custom Style Recharts Data Charts
Temperature and voltage charts with styled tooltips ... using TypeScript, so it's time to move on and make some various chart components.
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’m able to reproduce this bug. In my case I have
The Scatter in the example I’m looking at has three data points.
When in
MyCustomTooltip
I do some logging, I find thatprops.payload.length
is always 2, but the elements ofprops.payload
are identical in all cases except for the leftmost dots on the line. When I hover over the three leftmost dots on the line, I see that the three datapoints from myScatter
are being included there.I think this ticket should be reopened. @xile611 what do you think about reopening it?
@xile611 can we reopen this? This still isn’t solved and the bug is even visible on this example. Check out the index 10000, this should show the value.