Skip to content

Commit

Permalink
feat: Add the dataKey type to legend props (#4035)
Browse files Browse the repository at this point in the history
<!--- Provide a general summary of your changes in the Title above -->

## Description

<!--- Describe your changes in detail -->

## Related Issue

#2909
## Motivation and Context

<!--- Why is this change required? What problem does it solve? -->

## How Has This Been Tested?

<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, and the tests you ran
to -->
<!--- see how your change affects other areas of the code, etc. -->

## Screenshots (if appropriate):

## Types of changes

<!--- What types of changes does your code introduce? Put an `x` in all
the boxes that apply: -->

- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)

## Checklist:

<!--- Go over all the following points, and put an `x` in all the boxes
that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->

- [x] My code follows the code style of this project.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [ ] I have added tests to cover my changes.
- [ ] I have added a storybook story or extended an existing story to
show my changes
- [x] All new and existing tests passed.
  • Loading branch information
HHongSeungWoo committed Jan 3, 2024
1 parent 048d006 commit 0d94292
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/component/DefaultLegendContent.tsx
Expand Up @@ -49,6 +49,7 @@ export interface Payload {
formatter?: Formatter;
inactive?: boolean;
legendIcon?: ReactElement<SVGElement>;
dataKey?: DataKey<any>;
}
interface InternalProps {
content?: ContentType;
Expand All @@ -60,12 +61,12 @@ interface InternalProps {
payload?: Array<Payload>;
inactiveColor?: string;
formatter?: Formatter;
onMouseEnter?: (data: Payload & { dataKey?: DataKey<any> }, index: number, event: MouseEvent) => void;
onMouseLeave?: (data: Payload & { dataKey?: DataKey<any> }, index: number, event: MouseEvent) => void;
onClick?: (data: Payload & { dataKey?: DataKey<any> }, index: number, event: MouseEvent) => void;
onMouseEnter?: (data: Payload, index: number, event: MouseEvent) => void;
onMouseLeave?: (data: Payload, index: number, event: MouseEvent) => void;
onClick?: (data: Payload, index: number, event: MouseEvent) => void;
}

export type Props = InternalProps & PresentationAttributesAdaptChildEvent<any, ReactElement>;
export type Props = InternalProps & Omit<PresentationAttributesAdaptChildEvent<any, ReactElement>, keyof InternalProps>;

export class DefaultLegendContent extends PureComponent<Props> {
static displayName = 'Legend';
Expand Down
2 changes: 1 addition & 1 deletion src/util/ChartUtils.ts
Expand Up @@ -205,7 +205,7 @@ export interface FormattedGraphicalItem {
data?: ReadonlyArray<any>;
};
childIndex: number;
item: ReactElement<{ legendType?: LegendType; hide: boolean; name?: string; dataKey: unknown }>;
item: ReactElement<{ legendType?: LegendType; hide: boolean; name?: string; dataKey: DataKey<any> }>;
}

export type BarSetup = {
Expand Down

0 comments on commit 0d94292

Please sign in to comment.