Skip to content

Commit

Permalink
fix(line): update type for custom line canvas layers (#1499)
Browse files Browse the repository at this point in the history
Co-authored-by: Neil Kistner <[email protected]>
  • Loading branch information
Jakob Guddas and wyze authored May 1, 2021
1 parent 2675b60 commit 0454784
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/line/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { LegendProps } from '@nivo/legends'
import { Scale, ScaleFunc } from '@nivo/scales'
import { AxisProps, GridValues } from '@nivo/axes'
import { CrosshairType } from '@nivo/tooltip'
import { Line as D3Line } from 'd3-shape'

type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>

Expand Down Expand Up @@ -68,7 +69,7 @@ declare module '@nivo/line' {
export interface CustomLayerProps extends Omit<LineSvgProps, 'xScale' | 'yScale'> {
innerHeight: number
innerWidth: number
lineGenerator: (data: Datum[]) => string
lineGenerator: D3Line<[number, number]>
points: Point[]
series: ComputedSerie[]
xScale: ScaleFunc
Expand Down Expand Up @@ -213,8 +214,16 @@ declare module '@nivo/line' {
export class Line extends React.Component<LineSvgProps & Dimensions> {}
export class ResponsiveLine extends React.Component<LineSvgProps> {}

export interface CustomCanvasLayerProps extends CustomLayerProps {
ctx: CanvasRenderingContext2D
}

export type CustomCanvasLayer = (props: CustomCanvasLayerProps) => void
export type CanvasLayer = LineLayerType | CustomCanvasLayer

export interface LineCanvasProps extends LineProps {
pixelRatio?: number
layers?: CanvasLayer[]
}

export class LineCanvas extends React.Component<LineCanvasProps & Dimensions> {}
Expand Down

0 comments on commit 0454784

Please sign in to comment.