-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[charts] Add click listener to radar charts #18773
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Deploy preview: https://deploy-preview-18773--material-ui-x.netlify.app/ Updated pages: Bundle size reportTotal Size Change: 🔺+11KB(+0.08%) - Total Gzip Change: 🔺+2.91KB(+0.07%) Show details for 100 more bundles (22 more not shown)@mui/x-charts parsed: 🔺+1.53KB(+0.50%) gzip: 🔺+480B(+0.52%) |
CodSpeed Performance ReportMerging #18773 will not alter performanceComparing Summary
|
onAreaClick={(event, d) => setItemData(d)} | ||
onMarkClick={(event, d) => setItemData(d)} | ||
onAxisClick={(event, d) => setAxisData(d)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not clear for the user when a click happens in mark vs area
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would you thin if I put a radio button to select between mark and area?
Because I assume devs will never use both at the same time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good
- `onAreaClick` for click on a specific area. | ||
- `onMarkClick` for click on a specific mark. | ||
- `onAxisClick` for a click anywhere in the chart |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are the specific differences between them? Eg: A mark has access to the dataIndex, while area only has access to the series
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, basically they provide all the information they have
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now That I think about that the area could run some computation to know in which slice of the radar the pointer is and derive a dataIndex
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be an improvement, yeah
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 👍
onClick={(event) => onAreaClick?.(event, { type: 'radar', seriesId })} | ||
cursor={onAreaClick ? 'pointer' : 'unset'} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we have onAreaClick
here and in RadarSeriesArea
? Same for the mark
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the RadarSeriesPlot
renders both mark and area. So I need onAreaClick
/onMarkClick
.
Whereas RadarSeriesArea
only render the area and so has an onItemClick
That's weird but users should not use at the same time RadarSeriesArea
and RadarSeriesPlot
. SO I try to make this feature available for whatever composition strategy devs pick
The renders all series together, such that the area of the second series is on top of the marks of the first one.
The and components make it possible to render all marks on top of all areas. You can also use them to render components between the areas and the marks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why have both then? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why have both then? 🤔
Both what?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RadarSeriesPlot
and separate RadarSeriesArea
? We seem to only use RadarSeriesArea
in our code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but we export both such that devs who want the other approach get it out of the box.
The question is "If series A area is on top of series B". Should the series B mark be on top of series A or bellow.
We ended up deciding that, depending on how you want to interact both can make sense, and then we pick one solution for the single component chart but export components for both usecases
To redo RadarSeriesPlot
you would have to do the following
RadarSeriesPlot => <g>
<RadarSeriesArea seriesId={id1} />
<RadarSeriesMark seriesId={id1} />
<RadarSeriesArea seriesId={id2} />
<RadarSeriesMark seriesId={id2} />
<RadarSeriesArea seriesId={id3} />
<RadarSeriesMark seriesId={id3} />
</g>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, so it is a component to help users who want to have this different order?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, exactly. The docs can probably be improved if you did not get it
// The series to axis mapping is not yet-needed | ||
|
||
// const providedRotationAxisId = seriesItem.rotationAxisId; | ||
// const providedRadiusAxisId = seriesItem.radiusAxisId; | ||
|
||
// const axisKey = isRotationAxis ? providedXAxisId : providedYAxisId; | ||
// if (axisKey === undefined || axisKey === USED_AXIS_ID) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this comment provide any future value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically uncommenting them should maket the feature work for a polar bar/line chart. But I can remove if you find it too noisiy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can probably remove it for now unless you are working on that feature already 😆
Fix #18750
The implementation is an adaptation of the cartesian
onAxisClick
plus the line chart behavior withonItemClick
andonLineClick
.