diff --git a/packages/visx-shape/src/shapes/BarGroup.tsx b/packages/visx-shape/src/shapes/BarGroup.tsx index 08a921e91..c6ed88d2d 100644 --- a/packages/visx-shape/src/shapes/BarGroup.tsx +++ b/packages/visx-shape/src/shapes/BarGroup.tsx @@ -9,7 +9,7 @@ import { AnyScaleBand, AddSVGProps, BaseBarGroupProps, - BarGroup, + BarGroup as BarGroupType, GroupKey, Accessor, } from '../types'; @@ -32,7 +32,7 @@ export type BarGroupProps< /** Total height of the y-axis. */ height: number; /** Override render function which is passed the computed BarGroups. */ - children?: (barGroups: BarGroup[]) => React.ReactNode; + children?: (barGroups: BarGroupType[]) => React.ReactNode; }; /** @@ -73,7 +73,7 @@ export type BarGroupProps< * * Example: [https://airbnb.io/visx/bargroup](https://airbnb.io/visx/bargroup) */ -export default function BarGroupComponent< +export default function BarGroup< Datum extends DatumObject, Key extends GroupKey = GroupKey, X0Scale extends AnyScaleBand = AnyScaleBand, @@ -95,7 +95,7 @@ export default function BarGroupComponent< }: AddSVGProps, SVGRectElement>) { const barWidth = getBandwidth(x1Scale); - const barGroups: BarGroup[] = data.map((group, i) => ({ + const barGroups: BarGroupType[] = data.map((group, i) => ({ index: i, x0: x0Scale(x0(group))!, bars: keys.map((key, j) => { diff --git a/packages/visx-shape/src/shapes/BarGroupHorizontal.tsx b/packages/visx-shape/src/shapes/BarGroupHorizontal.tsx index 8f3f99a64..956668a19 100644 --- a/packages/visx-shape/src/shapes/BarGroupHorizontal.tsx +++ b/packages/visx-shape/src/shapes/BarGroupHorizontal.tsx @@ -8,7 +8,7 @@ import { AnyScaleBand, DatumObject, AddSVGProps, - BarGroupHorizontal, + BarGroupHorizontal as BarGroupHorizontalType, BaseBarGroupProps, GroupKey, Accessor, @@ -34,10 +34,10 @@ export type BarGroupHorizontalProps< /** Total width of the x-axis. */ width: number; /** Override render function which is passed the computed Ba/rGroups. */ - children?: (barGroups: BarGroupHorizontal[]) => React.ReactNode; + children?: (barGroups: BarGroupHorizontalType[]) => React.ReactNode; }; -export default function BarGroupHorizontalComponent< +export default function BarGroupHorizontal< Datum extends DatumObject, Key extends GroupKey = GroupKey, Y0Scale extends AnyScaleBand = AnyScaleBand, @@ -60,7 +60,7 @@ export default function BarGroupHorizontalComponent< }: AddSVGProps, SVGRectElement>) { const barHeight = getBandwidth(y1Scale); - const barGroups: BarGroupHorizontal[] = data.map((group, i) => ({ + const barGroups: BarGroupHorizontalType[] = data.map((group, i) => ({ index: i, y0: y0Scale(y0(group)) || 0, bars: keys.map((key, j) => { diff --git a/packages/visx-shape/src/shapes/BarStack.tsx b/packages/visx-shape/src/shapes/BarStack.tsx index 97e26bc78..f0ec14eb3 100644 --- a/packages/visx-shape/src/shapes/BarStack.tsx +++ b/packages/visx-shape/src/shapes/BarStack.tsx @@ -6,7 +6,7 @@ import { ScaleInput } from '@visx/scale'; import { PositionScale, AddSVGProps, - BarStack, + BarStack as BarStackType, BaseBarStackProps, StackKey, Accessor, @@ -32,7 +32,7 @@ export type BarStackProps< y1?: Accessor, ScaleInput>; }; -export default function BarStackComponent< +export default function BarStack< Datum, Key extends StackKey = StackKey, XScale extends PositionScale = PositionScale, @@ -64,7 +64,7 @@ export default function BarStackComponent< const stacks = stack(data); const barWidth = getBandwidth(xScale); - const barStacks: BarStack[] = stacks.map((barStack, i) => { + const barStacks: BarStackType[] = stacks.map((barStack, i) => { const { key } = barStack; return { index: i,