-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLineUtils.d.ts
118 lines (118 loc) · 3.43 KB
/
LineUtils.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
import { Canvas2dZoom } from ".";
export declare enum LabelPosition {
TOP_CENTER = "top-center",
TOP_RIGHT = "top-right",
TOP_LEFT = "top-left",
BOTTOM_CENTER = "bottom-center",
BOTTOM_RIGHT = "bottom-right",
BOTTOM_LEFT = "bottom-left",
LEFT = "left",
RIGHT = "right"
}
export interface ArrowConfig {
length: number;
angle: number;
filled: boolean;
}
export interface LabelConfig {
text: string;
size?: number;
position?: LabelPosition;
lineOffsetFactor?: number;
/**
* Default: false. If set to true, the label will be rotated with the same angle as the axis against a horizontal line
* If a number is provided, the label will be rotated by that angle, in radians
*/
rotated?: boolean|number;
font?: FontConfig;
/**
* See strokeStyle: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/strokeStyle
*/
style?: string;
}
export interface LineConfig {
arrows: {
start?: ArrowConfig;
end?: ArrowConfig;
};
label: LabelConfig;
/**
* See strokeStyle: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/strokeStyle
*/
style: string;
}
export interface TicksConfig {
length: number;
width: number;
/**
* See strokeStyle: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/strokeStyle
*/
style?: string;
font?: FontConfig;
grid?: boolean;
/** rotate labels by some angle, in radians */
labelRotation?: number;
}
export declare type TicksValuesConfig = TicksConfig & ({
valueRange: [number, number];
numberTicks: number;
} | {
values: Array<string>;
});
/**
* See https://developer.mozilla.org/en-US/docs/Web/CSS/font
*/
export interface FontConfigDetails {
size: string;
family: string;
style?: string;
weight?: string;
stretch?: string;
}
export declare type FontConfig = FontConfigDetails | string;
export interface SingleAxisConfig {
offsetBoundary: number;
offsetDrawn: boolean;
ticks: Partial<TicksValuesConfig>;
lineConfig: Partial<LineConfig>;
font?: FontConfig;
/**
* See strokeStyle: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/strokeStyle
*/
style?: string;
keepOffsetContent?: boolean;
}
export interface AxesConfig {
x: boolean|(Partial<SingleAxisConfig>&{position?: "bottom"|"top"});
y: boolean|(Partial<SingleAxisConfig>&{position?: "left"|"right"});
font?: FontConfig;
/**
* See strokeStyle: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/strokeStyle
*/
style?: string;
grid?: boolean;
/**
* Default: false
*/
keepOffsetContent?: boolean;
}
export declare class LineUtils {
/**
* Draw a static line that does not zoom or pan
* @param canvas
* @param x0
* @param y0
* @param x1
* @param y1
* @param arrowEnd
* @param arrowStart
*/
static drawLine(canvas: Canvas2dZoom, x0: number, y0: number, x1: number, y1: number, config?: Partial<LineConfig>): { close: () => void };
/**
* Add one or two coordinate axes to the canvas, consisting of static lines with optional arrow heads and labels, plus
* ticks that adapt to the zoom and pan state.
* @param canvas
* @param config
*/
static drawAxes(canvas: Canvas2dZoom, config?: Partial<AxesConfig>): { close: () => void };
}