Skip to content

Commit

Permalink
Categorical chart callback types (recharts#2739)
Browse files Browse the repository at this point in the history
  • Loading branch information
gromchen authored Dec 21, 2021
1 parent cb8b310 commit e71f351
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/chart/generateCategoricalChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,8 @@ export interface CategoricalChartState {
prevChildren?: any;
}

export type CategoricalChartFunc = (nextState: CategoricalChartState, event: any) => void;

export interface CategoricalChartProps {
syncId?: number | string;
syncMethod?: 'index' | 'value' | Function;
Expand All @@ -726,12 +728,12 @@ export interface CategoricalChartProps {
className?: string;
children?: any;
defaultShowTooltip?: boolean;
onClick?: any;
onMouseLeave?: any;
onMouseEnter?: any;
onMouseMove?: any;
onMouseDown?: any;
onMouseUp?: any;
onClick?: CategoricalChartFunc;
onMouseLeave?: CategoricalChartFunc;
onMouseEnter?: CategoricalChartFunc;
onMouseMove?: CategoricalChartFunc;
onMouseDown?: CategoricalChartFunc;
onMouseUp?: CategoricalChartFunc;
reverseStackOrder?: boolean;
id?: string;

Expand Down Expand Up @@ -1410,7 +1412,7 @@ export const generateCategoricalChart = ({
*/
handleMouseLeave = (e: any) => {
const { onMouseLeave } = this.props;
const nextState = { isTooltipActive: false };
const nextState: CategoricalChartState = { isTooltipActive: false };

this.setState(nextState);
this.triggerSyncEvent(nextState);
Expand Down Expand Up @@ -1459,19 +1461,17 @@ export const generateCategoricalChart = ({
const { onMouseDown } = this.props;

if (_.isFunction(onMouseDown)) {
const mouse = this.getMouseInfo(e);

onMouseDown(mouse, e);
const nextState: CategoricalChartState = this.getMouseInfo(e);
onMouseDown(nextState, e);
}
};

handleMouseUp = (e: any) => {
const { onMouseUp } = this.props;

if (_.isFunction(onMouseUp)) {
const mouse = this.getMouseInfo(e);

onMouseUp(mouse, e);
const nextState: CategoricalChartState = this.getMouseInfo(e);
onMouseUp(nextState, e);
}
};

Expand Down

0 comments on commit e71f351

Please sign in to comment.