diff --git a/packages/line/index.d.ts b/packages/line/index.d.ts index 771a134cb..d64dfc28d 100644 --- a/packages/line/index.d.ts +++ b/packages/line/index.d.ts @@ -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 = Pick> @@ -68,7 +69,7 @@ declare module '@nivo/line' { export interface CustomLayerProps extends Omit { innerHeight: number innerWidth: number - lineGenerator: (data: Datum[]) => string + lineGenerator: D3Line<[number, number]> points: Point[] series: ComputedSerie[] xScale: ScaleFunc @@ -213,8 +214,16 @@ declare module '@nivo/line' { export class Line extends React.Component {} export class ResponsiveLine extends React.Component {} + 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 {}