@mui/x-charts
Version:
The community edition of the Charts components (MUI X).
39 lines • 905 B
JavaScript
import * as React from 'react';
import { InteractionContext } from '../context/InteractionProvider';
import { useHighlighted } from '../context';
export const useInteractionItemProps = skip => {
const {
dispatch: dispatchInteraction
} = React.useContext(InteractionContext);
const {
setHighlighted,
clearHighlighted
} = useHighlighted();
if (skip) {
return () => ({});
}
const getInteractionItemProps = data => {
const onMouseEnter = () => {
dispatchInteraction({
type: 'enterItem',
data
});
setHighlighted({
seriesId: data.seriesId,
dataIndex: data.dataIndex
});
};
const onMouseLeave = () => {
dispatchInteraction({
type: 'leaveItem',
data
});
clearHighlighted();
};
return {
onMouseEnter,
onMouseLeave
};
};
return getInteractionItemProps;
};