Segment custom attributes for event handling
austin-knauer opened this issue · 1 comments
Do you want to request a feature or report a bug?
Feature
What is the current behaviour?
The event handlers that can be passed as props to the pie chart only take the event and the segment index. This probably works fine for handling events only related to the pie chart based on standard data, but since neither of these are really customizable through the segment data objects (other than maybe the label which can be accessed via event.target in a somewhat hacky way), it's hard to create custom interactivity. For example if the pie chart were based on a list of data where not every item was being passed into the data prop and therefore the segment index didn't correlate to the actual data index needed for handling the event in the context of the rest of the page outside the chart.
What is the expected behaviour?
It would be great if it were possible to specify a custom data attribute or even just the id to be assigned to the for each segment inside the data prop. e.g.:
<PieChart data={[{value: 1, title: "First", id: "first-segment", customData: "1" }]} />
would create a Path element with id="first-segment" and a data attribute like data-custom="1". Or really any way to pass in custom metadata about a segment that can be accessed through events, this is just a crude idea.
Steps to Reproduce the Problem
- ...
- ...
- ...
Specifications
- Version:
- Platform:
- Subsystem:
Hi @austin-knauer,
I expect the index returned from event handlers to always match the one of the relevant data
entry. Once you relate index and data
entry you should be able to hook in any custom logic. Consider that data
entries can have any extra property.