Skip to content

Commit

Permalink
fix: area color scale typing
Browse files Browse the repository at this point in the history
  • Loading branch information
marrouchi committed Dec 22, 2022
1 parent d3f1cd4 commit 57ea20e
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions packages/ez-react/src/components/Area.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,16 @@ export const Area: FC<AreaProps> = ({
}) => {
const { colorScale } = useColorScale();

const color = useMemo(
() =>
colorScale.isDefined()
? (colorScale as unknown as ScaleOrdinal).scale(yDomainKey)
: area.fill,
[area.fill, colorScale, yDomainKey]
);
const color = useMemo(() => {
if (colorScale.isDefined()) {
if (colorScale.constructor.name === 'ScaleOrdinal') {
return (colorScale as any as ScaleOrdinal).scale(yDomainKey);
} else {
throw new Error('Area shape does not support non ordinal color scale');
}
}
return area.fill;
}, [area.fill, colorScale, yDomainKey]);

return (
<Points
Expand Down

0 comments on commit 57ea20e

Please sign in to comment.