recharts/recharts

payload=[] for Tooltip when allowDuplicatedCategory={false} in XAxis

Open

#2,348 opened on Dec 21, 2020

View on GitHub
 (11 comments) (4 reactions) (0 assignees)TypeScript (1,637 forks)batch import
buggood first issue

Repository metrics

Stars
 (21,783 stars)
PR merge metrics
 (Avg merge 3d 21h) (86 merged PRs in 30d)

Description

  • I have searched the issues of this repository and believe that this is not a duplicate.

Reproduction link

Edit on CodeSandbox

Steps to reproduce

In demo link just hovering over a bar and open console. The Tooltip don't show and payload = [].

If just change this line: <XAxis dataKey="name" allowDuplicatedCategory={false} />

for this one

<XAxis dataKey="name" allowDuplicatedCategory={true} />

The Tooltip show and payload = [{ color: "#ff7300", dataKey: "count", fill: "#ff7300", formatter: undefined, name: "count", payload: { count: 32, sum: [12, 16] }, type: undefined, unit: undefined, value: 32 }].

What is expected?

The Tooltip should be displayed when hovering over a bar and payload have array with data. http://prntscr.com/w70392

What is actually happening?

Adding allowDuplicatedCategory={false} to XAxis component in BarChart makes the Tooltip stop working. The Tooltip just don't show when hovering over a bar and payload = []; http://prntscr.com/w6zywz

Environment Info
Recharts v1.8.5
React 16.13.1
System Windows 10 Home 2004
Browser Google Chrome (87.0.4280.88)

Contributor guide