Skip to content

The dataKey does not exist in the payload of the Legend within the PieChart. #7056

Description

@hirotomoyamada

What is the current behavior?

The dataKey does not exist in the payload of the Legend within the PieChart.

{
  "value": "safari",
  "color": "",
  "payload": {
    "browser": "safari",
    "downloads": 2159,
    "visits": 4048
  },
  "type": "rect"
}

The payload of the Tooltip contains a dataKey.

{
  "stroke": "",
  "dataKey": "visits",
  "nameKey": "browser",
  "name": "chrome",
  "hide": false,
  "graphicalItemId": "recharts-pie-_r_1_",
  "payload": {
    "browser": "chrome",
    "downloads": 4545,
    "visits": 2764
  },
  "value": 2764
}

Other charts (LineChart and AreaChart) have a dataKey in their payload. For compatibility, we should include dataKey within the payload.

Additionally, if multiple Pie elements exist within a PieChart, the payload of the Legend cannot determine which Pie the data belongs to if the dataKey is missing.

What is the expected behavior?

Please include the dataKey in the payload of Legend.

{
  "dataKey": "visits",
  "value": "safari",
  "color": "",
  "payload": {
    "browser": "safari",
    "downloads": 2159,
    "visits": 4048
  },
  "type": "rect"
}

Which versions of Recharts, and which browser / OS are affected by this issue? Did this work in previous versions of Recharts?

The version is 3.7.0, and dataKey has likely never been provided.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementEnhancement to a current APIfeature requestIssues that are feature requests

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions