-
-
Notifications
You must be signed in to change notification settings - Fork 1k
/
__old_index.d.ts
223 lines (186 loc) · 5.76 KB
/
__old_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
215
216
217
218
219
220
221
222
223
import * as React from 'react'
import {
Dimensions,
Box,
Theme,
ModernMotionProps,
CartesianMarkerProps,
SvgDefsAndFill,
ValueFormat,
DatumValue as CoreDatumValue,
} from '@nivo/core'
import { OrdinalColorScaleConfig } from '@nivo/colors'
import { LegendProps } from '@nivo/legends'
import { ScaleSpec, Scale, TicksSpec } from '@nivo/scales'
import { AxisProps } 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>>
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'> {
innerHeight: number
innerWidth: number
lineGenerator: D3Line<Array<ComputedDatum['position']>>
points: Point[]
series: ComputedSerie[]
xScale: Scale<unknown, unknown>
yScale: Scale<unknown, unknown>
}
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 AccessorFunc = (datum: Point['data']) => string
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?: ScaleSpec
xFormat?: ValueFormat<DatumValue>
yScale?: ScaleSpec
yFormat?: ValueFormat<DatumValue>
layers?: Layer[]
margin?: Box
curve?:
| 'basis'
| 'cardinal'
| 'catmullRom'
| 'linear'
| 'monotoneX'
| 'monotoneY'
| 'natural'
| 'step'
| 'stepAfter'
| 'stepBefore'
lineWidth?: number
colors?: OrdinalColorScaleConfig
theme?: Theme
axisTop?: AxisProps | null
axisRight?: AxisProps | null
axisBottom?: AxisProps | null
axisLeft?: AxisProps | null
enableGridX?: boolean
gridXValues?: TicksSpec<DatumValue>
enableGridY?: boolean
gridYValues?: TicksSpec<DatumValue>
enablePoints?: boolean
pointSymbol?: (props: Readonly<PointSymbolProps>) => React.ReactNode
pointSize?: number
pointColor?: any
pointBorderWidth?: number
pointBorderColor?: any
enableArea?: boolean
areaOpacity?: number
areaBaselineValue?: DatumValue
markers?: CartesianMarkerProps[]
isInteractive?: boolean
onMouseEnter?: PointMouseHandler
onMouseMove?: PointMouseHandler
onMouseLeave?: PointMouseHandler
onClick?: PointMouseHandler
debugMesh?: boolean
enableSlices?: 'x' | 'y' | false
debugSlices?: boolean
sliceTooltip?: SliceTooltip
tooltipFormat?: ValueFormat<DatumValue>
tooltip?: PointTooltip
enableCrosshair?: boolean
crosshairType?: CrosshairType
legends?: LegendProps[]
}
export interface LineSvgProps extends LineProps, ModernMotionProps, SvgDefsAndFill<Datum> {
enablePointLabel?: boolean
pointLabel?: string | AccessorFunc
pointLabelYOffset?: number
areaBlendMode?: string
role?: string
useMesh?: boolean
}
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 Omit<LineProps, 'layers'> {
pixelRatio?: number
layers?: CanvasLayer[]
}
export class LineCanvas extends React.Component<LineCanvasProps & Dimensions> {}
export class ResponsiveLineCanvas extends React.Component<LineCanvasProps> {}
}