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
feat: Funnel support custom shape prop #3886
feat: Funnel support custom shape prop #3886
Conversation
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.
Would like to see if we can remove that cast
src/util/ActiveShapeUtils.tsx
Outdated
|
||
if (isValidElement(option)) { | ||
shape = cloneElement(option, props); | ||
nextProps = propTransformer(option.props as OptionType, props); |
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.
any way we don't have to cast here?
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.
looks like there is. 😃
src/util/ActiveShapeUtils.tsx
Outdated
if (isValidElement<OptionType>(option)) { | ||
nextProps = propTransformer(option.props, props); | ||
shape = cloneElement<OptionType>(option, nextProps); |
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.
even though we remove as
this is still casting.
Its probably fine since we're doing all of the checks we do here but still
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.
Made another update check again, please.
shape: { | ||
description: 'The customized shape to be rendered.', | ||
table: { | ||
type: { | ||
summary: 'Function | boolean | ReactElement | object', | ||
}, | ||
defaultValue: undefined, | ||
category: 'General', | ||
}, | ||
}, |
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.
I believe this is documented in multiple places. Should we extract a shared description, and import it?
That would enforce standardised user facing communication for this property.
test/chart/FunnelChart.spec.tsx
Outdated
@@ -229,4 +229,55 @@ describe('<FunnelChart />', () => { | |||
const activeShape = container.querySelectorAll('.recharts-active-shape'); | |||
expect(activeShape).toHaveLength(0); | |||
}); | |||
|
|||
test('renders customized shape when shape is set to be a function', () => { |
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.
Just a curious idea:
How about instead of duplicating these tests per component, why not create a single test file, for shape, and test all supported components at once with a parametrised test?
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.
That would further enforce standardised behaviour and reduce copy pasted code /test cases
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.
I did this for the Funnel cases, can you take a look and confirm I'm on the right path. If so, I'll convert the others.
1c2cbc4
to
996ed51
Compare
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.
LGTM!
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.
Thank you for cleaning up the tests! Appreciate it!
## Description Add support for shape prop in Funnel for user to provide a customized shape. ## Related Issue <!--- This project only accepts pull requests related to open issues --> <!--- If suggesting a new feature or change, please discuss it in an issue first --> <!--- If fixing a bug, there should be an issue describing it with steps to reproduce --> <!--- Please link to the issue here: --> recharts#3832 ## Motivation and Context <!--- Why is this change required? What problem does it solve? --> Unified api for shape/activeShape support between Funnel/Line/Bar/RadialBar/Scatter ## How Has This Been Tested? unit tests and storybook <!--- 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: --> - [ ] Bug fix (non-breaking change which fixes an issue) - [x] 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. - [x] My change requires a change to the documentation. - [x] I have updated the documentation accordingly. - [x] I have added tests to cover my changes. - [x] I have added a storybook story or extended an existing story to show my changes - [x] All new and existing tests passed.
Description
Add support for shape prop in Funnel for user to provide a customized shape.
Related Issue
#3832
Motivation and Context
Unified api for shape/activeShape support between Funnel/Line/Bar/RadialBar/Scatter
How Has This Been Tested?
unit tests and storybook
Screenshots (if appropriate):
Types of changes
Checklist: