Skip to content

Commit

Permalink
fix(ChartScatter): consider bubbleProperty if it is set (#9282)
Browse files Browse the repository at this point in the history
bubbleProperty is only considered if the size prop is undefined, therefore set
default size function only if bubbleProperty is not set.

Ref. https://github.com/FormidableLabs/victory/blob/bbc1e2a39448d7fb6724f916afacf5f6eab7d1b3/packages/victory-scatter/src/helper-methods.tsx#L35-L43
Signed-off-by: Andreas Gerstmayr <[email protected]>
  • Loading branch information
andreasgerstmayr authored Aug 16, 2023
1 parent 230613a commit 6020af4
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,6 @@ export const ChartScatter: React.FunctionComponent<ChartScatterProps> = ({

// destructure last
theme = getTheme(themeColor),
size = ({ active }) => (active ? ChartScatterStyles.activeSize : ChartScatterStyles.size),
...rest
}: ChartScatterProps) => {
// Clone so users can override container props
Expand All @@ -455,8 +454,14 @@ export const ChartScatter: React.FunctionComponent<ChartScatterProps> = ({
...containerComponent.props
});

// bubbleProperty is only considered if the size prop is undefined, therefore set
// default size function only if bubbleProperty is not set.
if (typeof rest.size === "undefined" && typeof rest.bubbleProperty === "undefined") {

Check failure on line 459 in packages/react-charts/src/components/ChartScatter/ChartScatter.tsx

View workflow job for this annotation

GitHub Actions / lint

Replace `"undefined"·&&·typeof·rest.bubbleProperty·===·"undefined"` with `'undefined'·&&·typeof·rest.bubbleProperty·===·'undefined'`
rest.size = ({ active }) => (active ? ChartScatterStyles.activeSize : ChartScatterStyles.size);
}

// Note: containerComponent is required for theme
return <VictoryScatter containerComponent={container} size={size} theme={theme} {...rest} />;
return <VictoryScatter containerComponent={container} theme={theme} {...rest} />;
};
ChartScatter.displayName = 'ChartScatter';

Expand Down

0 comments on commit 6020af4

Please sign in to comment.