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.

ComposedChart w/ different tooltips per datasets

See original GitHub issue

Do 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:closed
  • Created 4 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

12reactions
ghostcommented, Jul 15, 2020

I’m able to reproduce this bug. In my case I have

<ComposedChart>
  <Tooltip content={<MyCustomTooltip />} />
  <Line someProps={...}>
  </Line>
  <Scatter someProps={...}>
  </Scatter>
</ComposedChart>

The Scatter in the example I’m looking at has three data points.

When in MyCustomTooltip I do some logging, I find that props.payload.length is always 2, but the elements of props.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 my Scatter are being included there.

I think this ticket should be reopened. @xile611 what do you think about reopening it?

5reactions
juliusdanekcommented, Jun 9, 2022

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

Read more comments on GitHub >

github_iconTop 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 >

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