Skip to content

Commit

Permalink
fix(bar): fix type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
wyze committed Jul 2, 2021
1 parent cbf1351 commit 57d50ab
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
14 changes: 10 additions & 4 deletions packages/bar/src/BarCanvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,17 @@ const InnerBarCanvas = <RawDatum extends BarDatum>({
const { showTooltipFromEvent, hideTooltip } = useTooltip()

const formatValue = useValueFormatter(valueFormat)
const getBorderColor = useInheritedColor<ComputedBarDatum<RawDatum>>(borderColor, theme)
const getBorderColor = useInheritedColor<ComputedBarDatumWithValue<RawDatum>>(
borderColor,
theme
)
const getColor = useOrdinalColorScale(colors, colorBy)
const getIndex = usePropertyAccessor(indexBy)
const getLabel = usePropertyAccessor(label)
const getLabelColor = useInheritedColor<ComputedBarDatum<RawDatum>>(labelTextColor, theme)
const getLabelColor = useInheritedColor<ComputedBarDatumWithValue<RawDatum>>(
labelTextColor,
theme
)
const getTooltipLabel = usePropertyAccessor(tooltipLabel)

const options = {
Expand Down Expand Up @@ -362,11 +368,11 @@ const InnerBarCanvas = <RawDatum extends BarDatum>({
barsWithValue.forEach(bar => {
renderBar(ctx, {
bar,
borderColor: getBorderColor(bar),
borderColor: getBorderColor(bar) as string,
borderRadius,
borderWidth,
label: getLabel(bar.data),
labelColor: getLabelColor(bar),
labelColor: getLabelColor(bar) as string,
shouldRenderLabel: shouldRenderLabel(bar),
})
})
Expand Down
5 changes: 4 additions & 1 deletion packages/bar/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,10 @@ export interface BarItemProps<RawDatum>
export type RenderBarProps<RawDatum> = Omit<
BarItemProps<RawDatum>,
'isInteractive' | 'style' | 'tooltip'
>
> & {
borderColor: string
labelColor: string
}

export interface BarTooltipProps<RawDatum> extends ComputedDatum<RawDatum> {
color: string
Expand Down

0 comments on commit 57d50ab

Please sign in to comment.