Skip to content

Commit

Permalink
fix(radar): typing for custom functions (#1089)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlaaZorkane authored Oct 30, 2020
1 parent 32f4823 commit 20a5c12
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions packages/radar/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,28 @@ import { OrdinalColorsInstruction, InheritedColorProp } from '@nivo/colors'
import { LegendProps } from '@nivo/legends'

declare module '@nivo/radar' {
type IndexByCustomFunctiono<D = any> = (datum: D) => string | number
type GridLabelCustomFunction = (...args: any[]) => string | JSX.Element
type CustomDotSymbol = (...args: any[]) => React.ReactNode
type CustomDotLabel = (...args: any[]) => React.ReactNode
type CustomFormatter = (...args: any[]) => React.ReactNode
export type GridLabelProps = {
id: string
anchor: 'start' | 'middle' | 'end'
angle: number
}
export type DotSymbolProps = {
size: number
color: InheritedColorProp
borderWidth: number
borderColor: InheritedColorProp
}

type IndexByCustomFunction<D = any> = (datum: D) => string | number
export type CustomGridLabel = React.FC<GridLabelProps>
export type CustomDotSymbol = React.FC<DotSymbolProps>
export type CustomDotLabel = (...args: any[]) => React.ReactNode
export type CustomFormatter = (...args: any[]) => React.ReactNode

interface CommonRadarProps<Datum = any> {
data: object[]
keys: (string | number)[]
indexBy: number | string | IndexByCustomFunctiono<Datum>
indexBy: number | string | IndexByCustomFunction<Datum>
maxValue?: 'auto' | number

margin?: Box
Expand All @@ -33,7 +45,7 @@ declare module '@nivo/radar' {

gridLevels?: number
gridShape?: 'circular' | 'linear'
gridLabel?: GridLabelCustomFunction
gridLabel?: CustomGridLabel
gridLabelOffset?: number

enableDots?: boolean
Expand All @@ -55,7 +67,7 @@ declare module '@nivo/radar' {
isInteractive?: boolean
tooltipFormat?: string | CustomFormatter

legends: LegendProps[]
legends?: LegendProps[]
role?: string
}

Expand Down

0 comments on commit 20a5c12

Please sign in to comment.