Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(line): update type for custom line canvas layers #1499

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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