-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtypes.ts
100 lines (83 loc) · 2 KB
/
types.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
export interface IDrawData<T = any> {
mask: Path2D;
data: Readonly<T>;
}
export interface IDrawBarData<T = any> extends IDrawData<T> {
bars: ReadonlyArray<Path2D>;
}
export interface ICanvas {
ratio: number;
}
export interface IEventHandlers<C = Function, H = Function> {
onClick?: C;
onHoverChange?: H;
}
export interface IHoverOptions {
hoverColor: string;
}
export interface IParams<P extends IDrawData, O extends IEventHandlers> {
canvas: HTMLCanvasElement;
drawData: ReadonlyArray<Readonly<P>>;
options: Readonly<O>;
columns?: ReadonlyArray<string>;
}
export interface IPoint {
x: number;
y: number;
}
export interface ISize {
width: number;
height: number;
}
export interface IPadding {
sPadding: number;
vPadding: number;
}
export interface IEdges {
top: number;
bottom: number;
}
export interface IFooterOptions {
footer: number;
}
export type IGeometry = ISize & IPadding & IEdges & IFooterOptions;
export interface IRowOptions {
rowCount: number;
rowStroke: number;
rowColor: string;
rowMargin: number;
rowFont?: string;
rowFontSize: number;
rowSkeleton?: boolean;
rowFontAlign: 'left' | 'right';
rowFontColor?: string;
rowRenderValue?: (value: number) => string;
footerColor?: string;
footerMargin: number;
}
export interface ILineOptions {
lineStroke: number;
lineSmooth?: boolean;
lineColor: string;
lineFill: string | ReadonlyArray<string>;
pointRadius: number;
}
export interface IBarOptions {
barColors: ReadonlyArray<string>,
barWidth: number;
barMargin: number;
barRadius: number;
stacked?: boolean;
}
export type IDrawBarOptions = IEventHandlers & IBarOptions;
export type IDrawLevelOptions = IEventHandlers & IRowOptions & IGeometry;
export type IDrawLineOptions = IDrawLevelOptions & ILineOptions;
export interface IHoverRenderData<P extends IDrawData> {
items: ReadonlyArray<Readonly<P>>;
fill: (color?: string) => string;
}
export interface IHoverData<T> {
data: Readonly<T>;
clientX: number;
clientY: number;
}