Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"componentDescription": "",
"propDescriptions": {
"onItemClick": {
"description": "Callback fired when clicking on a scatter item.",
"description": "Callback fired when a marker is clicked directly and <code>disableHitArea</code> is <code>true</code>. When <code>disableHitArea</code> is <code>false</code>, use <code>onItemClick</code> on the chart container to handle closest-point clicks.",
"typeDescriptions": {
"event": {
"name": "event",
Expand Down
12 changes: 10 additions & 2 deletions packages/x-charts/src/ScatterChart/ScatterPlot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,15 @@ export interface ScatterPlotSlotProps extends ScatterSlotProps {

export type RendererType = 'svg-single' | 'svg-batch';

export interface ScatterPlotProps extends Pick<ScatterProps, 'onItemClick' | 'classes'> {
export interface ScatterPlotProps extends Pick<ScatterProps, 'classes'> {
className?: string;
/**
* Callback fired when a marker is clicked directly and `disableHitArea` is `true`.
* When `disableHitArea` is `false`, use `onItemClick` on the chart container to handle closest-point clicks.
* @param {MouseEvent} event Mouse event recorded on the `<svg/>` element.
* @param {ScatterItemIdentifier} scatterItemIdentifier The scatter item identifier.
Comment on lines +38 to +42

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's true but at the ScatterChart level.

For the props of the ScatterPlot, the onItemClick will be trigger independently from the disableHitArea value.

This logic is just in the useScatterChartProps that

  • if disableHitArea=true => the onItemClick is propagated to the ScatterPlot
  • if disableHitArea=false => the onItemClick is propagated to the DataProvider

https://github.com/mui/mui-x/blob/master/packages/x-charts/src/ScatterChart/useScatterChartProps.ts#L75-L77

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wdyt now?

image

*/
onItemClick?: ScatterProps['onItemClick'];
/**
* Overridable component slots.
* @default {}
Expand Down Expand Up @@ -155,7 +162,8 @@ ScatterPlot.propTypes = {
// | To update them edit the TypeScript types and run "pnpm proptypes" |
// ----------------------------------------------------------------------
/**
* Callback fired when clicking on a scatter item.
* Callback fired when a marker is clicked directly and `disableHitArea` is `true`.
* When `disableHitArea` is `false`, use `onItemClick` on the chart container to handle closest-point clicks.
* @param {MouseEvent} event Mouse event recorded on the `<svg/>` element.
* @param {ScatterItemIdentifier} scatterItemIdentifier The scatter item identifier.
*/
Expand Down
Loading