/
index.d.ts
214 lines (180 loc) · 5.35 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
/*
* This file is part of the nivo project.
*
* Copyright 2016-present, Raphaël Benitte.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import * as React from 'react'
import {
Dimensions,
Box,
Theme,
MotionProps,
CartesianMarkerProps,
SvgDefsAndFill,
DataFormatter,
DatumValue as CoreDatumValue,
} from '@nivo/core'
import { OrdinalColorsInstruction } from '@nivo/colors'
import { LegendProps } from '@nivo/legends'
import { Scale, ScaleFunc } from '@nivo/scales'
import { AxisProps } from '@nivo/axes'
import { CrosshairType } from '@nivo/tooltip'
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>
declare module '@nivo/line' {
export type DatumValue = CoreDatumValue
export interface Datum {
x?: DatumValue | null
y?: DatumValue | null
[key: string]: any
}
export interface ComputedDatum {
data: Datum
position: {
x: number
y: number
}
}
export interface Serie {
id: string | number
data: Datum[]
[key: string]: any
}
export interface ComputedSerie {
id: string | number
data: ComputedDatum[]
color?: string
[key: string]: any
}
export type LineLayerType =
| 'grid'
| 'markers'
| 'axes'
| 'areas'
| 'crosshair'
| 'lines'
| 'slices'
| 'points'
| 'mesh'
| 'legends'
export interface CustomLayerProps extends Omit<LineSvgProps, 'xScale' | 'yScale'> {
xScale: ScaleFunc
yScale: ScaleFunc
}
export type CustomLayer = (props: CustomLayerProps) => React.ReactNode
export type Layer = LineLayerType | CustomLayer
export interface Point {
id: string
index: number
serieId: string | number
serieColor: string
x: number
y: number
color: string
borderColor: string
data: {
x: DatumValue
xFormatted: string | number
y: DatumValue
yFormatted: string | number
yStacked?: number
}
}
export type PointMouseHandler = (point: Point, event: React.MouseEvent) => void
export interface PointTooltipProps {
point: Point
}
export type PointTooltip = React.FunctionComponent<PointTooltipProps>
export interface SliceTooltipProps {
axis: 'x' | 'y'
slice: {
id: DatumValue
height: number
width: number
x0: number
x: number
y0: number
y: number
points: Point[]
}
}
export type SliceTooltip = React.FunctionComponent<SliceTooltipProps>
export interface PointSymbolProps {
borderColor: string
borderWidth: number
color: string
datum: Datum
size: number
}
export interface LineProps {
data: Serie[]
xScale?: Scale
xFormat?: string | DataFormatter
yScale?: Scale
yFormat?: string | DataFormatter
layers?: Layer[]
margin?: Box
curve?:
| 'basis'
| 'cardinal'
| 'catmullRom'
| 'linear'
| 'monotoneX'
| 'monotoneY'
| 'natural'
| 'step'
| 'stepAfter'
| 'stepBefore'
lineWidth?: number
colors?: OrdinalColorsInstruction
theme?: Theme
axisTop?: AxisProps | null
axisRight?: AxisProps | null
axisBottom?: AxisProps | null
axisLeft?: AxisProps | null
enableGridX?: boolean
gridXValues?: number | number[] | string[] | Date[]
enableGridY?: boolean
gridYValues?: number | number[] | string[] | Date[]
enablePoints?: boolean
pointSymbol?: (props: Readonly<PointSymbolProps>) => React.ReactNode
pointSize?: number
pointColor?: any
pointBorderWidth?: number
pointBorderColor?: any
enableArea?: boolean
areaOpacity?: number
areaBaseDatumValue?: DatumValue
markers?: CartesianMarkerProps[]
isInteractive?: boolean
onMouseEnter?: PointMouseHandler
onMouseMove?: PointMouseHandler
onMouseLeave?: PointMouseHandler
onClick?: PointMouseHandler
debugMesh?: boolean
enableSlices?: 'x' | 'y' | false
debugSlices?: boolean
sliceTooltip?: SliceTooltip
tooltipFormat?: DataFormatter | string
tooltip?: PointTooltip
enableCrosshair?: boolean
crosshairType?: CrosshairType
legends?: LegendProps[]
}
export interface LineSvgProps extends LineProps, MotionProps, SvgDefsAndFill<Datum> {
enablePointLabel?: boolean
pointLabel?: string
pointLabelYOffset?: number
areaBlendMode?: string
useMesh?: boolean
}
export class Line extends React.Component<LineSvgProps & Dimensions> {}
export class ResponsiveLine extends React.Component<LineSvgProps> {}
export interface LineCanvasProps extends LineProps {
pixelRatio?: number
}
export class LineCanvas extends React.Component<LineCanvasProps & Dimensions> {}
export class ResponsiveLineCanvas extends React.Component<LineCanvasProps> {}
}