-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcore.scale.d.ts
More file actions
343 lines (343 loc) · 9.26 KB
/
core.scale.d.ts
File metadata and controls
343 lines (343 loc) · 9.26 KB
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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
export default class Scale extends Element<import("../types/basic.js").AnyObject, import("../types/basic.js").AnyObject> {
constructor(cfg: any);
/** @type {string} */
id: string;
/** @type {string} */
type: string;
/** @type {any} */
options: any;
/** @type {CanvasRenderingContext2D} */
ctx: CanvasRenderingContext2D;
/** @type {Chart} */
chart: Chart;
/** @type {number} */
top: number;
/** @type {number} */
bottom: number;
/** @type {number} */
left: number;
/** @type {number} */
right: number;
/** @type {number} */
width: number;
/** @type {number} */
height: number;
_margins: {
left: number;
right: number;
top: number;
bottom: number;
};
/** @type {number} */
maxWidth: number;
/** @type {number} */
maxHeight: number;
/** @type {number} */
paddingTop: number;
/** @type {number} */
paddingBottom: number;
/** @type {number} */
paddingLeft: number;
/** @type {number} */
paddingRight: number;
/** @type {string=} */
axis: string | undefined;
/** @type {number=} */
labelRotation: number | undefined;
min: any;
max: any;
_range: {
min: number;
max: number;
};
/** @type {Tick[]} */
ticks: Tick[];
/** @type {object[]|null} */
_gridLineItems: object[] | null;
/** @type {object[]|null} */
_labelItems: object[] | null;
/** @type {object|null} */
_labelSizes: object | null;
_length: number;
_maxLength: number;
_longestTextCache: {};
/** @type {number} */
_startPixel: number;
/** @type {number} */
_endPixel: number;
_reversePixels: boolean;
_userMax: any;
_userMin: any;
_suggestedMax: any;
_suggestedMin: any;
_ticksLength: number;
_borderValue: number;
_cache: {};
_dataLimitsCached: boolean;
$context: any;
/**
* @param {any} options
* @since 3.0
*/
init(options: any): void;
/**
* Parse a supported input value to internal representation.
* @param {*} raw
* @param {number} [index]
* @since 3.0
*/
parse(raw: any, index?: number): any;
/**
* @return {{min: number, max: number, minDefined: boolean, maxDefined: boolean}}
* @protected
* @since 3.0
*/
protected getUserBounds(): {
min: number;
max: number;
minDefined: boolean;
maxDefined: boolean;
};
/**
* @param {boolean} canStack
* @return {{min: number, max: number}}
* @protected
* @since 3.0
*/
protected getMinMax(canStack: boolean): {
min: number;
max: number;
};
/**
* Get the padding needed for the scale
* @return {{top: number, left: number, bottom: number, right: number}} the necessary padding
* @private
*/
private getPadding;
/**
* Returns the scale tick objects
* @return {Tick[]}
* @since 2.7
*/
getTicks(): Tick[];
/**
* @return {string[]}
*/
getLabels(): string[];
/**
* @return {import('../types.js').LabelItem[]}
*/
getLabelItems(chartArea?: import("../types.js").ChartArea): import('../types.js').LabelItem[];
beforeLayout(): void;
beforeUpdate(): void;
/**
* @param {number} maxWidth - the max width in pixels
* @param {number} maxHeight - the max height in pixels
* @param {{top: number, left: number, bottom: number, right: number}} margins - the space between the edge of the other scales and edge of the chart
* This space comes from two sources:
* - padding - space that's required to show the labels at the edges of the scale
* - thickness of scales or legends in another orientation
*/
update(maxWidth: number, maxHeight: number, margins: {
top: number;
left: number;
bottom: number;
right: number;
}): void;
/**
* @protected
*/
protected configure(): void;
_alignToPixels: any;
afterUpdate(): void;
beforeSetDimensions(): void;
setDimensions(): void;
afterSetDimensions(): void;
_callHooks(name: any): void;
beforeDataLimits(): void;
determineDataLimits(): void;
afterDataLimits(): void;
beforeBuildTicks(): void;
/**
* @return {object[]} the ticks
*/
buildTicks(): object[];
afterBuildTicks(): void;
beforeTickToLabelConversion(): void;
/**
* Convert ticks to label strings
* @param {Tick[]} ticks
*/
generateTickLabels(ticks: Tick[]): void;
afterTickToLabelConversion(): void;
beforeCalculateLabelRotation(): void;
calculateLabelRotation(): void;
afterCalculateLabelRotation(): void;
afterAutoSkip(): void;
beforeFit(): void;
fit(): void;
_calculatePadding(first: any, last: any, sin: any, cos: any): void;
/**
* Handle margins and padding interactions
* @private
*/
private _handleMargins;
afterFit(): void;
/**
* @return {boolean}
*/
isHorizontal(): boolean;
/**
* @return {boolean}
*/
isFullSize(): boolean;
/**
* @param {Tick[]} ticks
* @private
*/
private _convertTicksToLabels;
/**
* @return {{ first: object, last: object, widest: object, highest: object, widths: Array, heights: array }}
* @private
*/
private _getLabelSizes;
/**
* Returns {width, height, offset} objects for the first, last, widest, highest tick
* labels where offset indicates the anchor point offset from the top in pixels.
* @return {{ first: object, last: object, widest: object, highest: object, widths: Array, heights: array }}
* @private
*/
private _computeLabelSizes;
/**
* Used to get the label to display in the tooltip for the given value
* @param {*} value
* @return {string}
*/
getLabelForValue(value: any): string;
/**
* Returns the location of the given data point. Value can either be an index or a numerical value
* The coordinate (0, 0) is at the upper-left corner of the canvas
* @param {*} value
* @param {number} [index]
* @return {number}
*/
getPixelForValue(value: any, index?: number): number;
/**
* Used to get the data value from a given pixel. This is the inverse of getPixelForValue
* The coordinate (0, 0) is at the upper-left corner of the canvas
* @param {number} pixel
* @return {*}
*/
getValueForPixel(pixel: number): any;
/**
* Returns the location of the tick at the given index
* The coordinate (0, 0) is at the upper-left corner of the canvas
* @param {number} index
* @return {number}
*/
getPixelForTick(index: number): number;
/**
* Utility for getting the pixel location of a percentage of scale
* The coordinate (0, 0) is at the upper-left corner of the canvas
* @param {number} decimal
* @return {number}
*/
getPixelForDecimal(decimal: number): number;
/**
* @param {number} pixel
* @return {number}
*/
getDecimalForPixel(pixel: number): number;
/**
* Returns the pixel for the minimum chart value
* The coordinate (0, 0) is at the upper-left corner of the canvas
* @return {number}
*/
getBasePixel(): number;
/**
* @return {number}
*/
getBaseValue(): number;
/**
* @protected
*/
protected getContext(index: any): any;
/**
* @return {number}
* @private
*/
private _tickSize;
/**
* @return {boolean}
* @private
*/
private _isVisible;
/**
* @private
*/
private _computeGridLineItems;
/**
* @private
*/
private _computeLabelItems;
_getXAxisLabelAlignment(): string;
_getYAxisLabelAlignment(tl: any): {
textAlign: string;
x: any;
};
/**
* @private
*/
private _computeLabelArea;
/**
* @protected
*/
protected drawBackground(): void;
getLineWidthForValue(value: any): any;
/**
* @protected
*/
protected drawGrid(chartArea: any): void;
/**
* @protected
*/
protected drawBorder(): void;
/**
* @protected
*/
protected drawLabels(chartArea: any): void;
/**
* @protected
*/
protected drawTitle(): void;
draw(chartArea: any): void;
/**
* @return {object[]}
* @private
*/
private _layers;
/**
* Returns visible dataset metas that are attached to this scale
* @param {string} [type] - if specified, also filter by dataset type
* @return {object[]}
*/
getMatchingVisibleMetas(type?: string): object[];
/**
* @param {number} index
* @return {object}
* @protected
*/
protected _resolveTickFontOptions(index: number): object;
/**
* @protected
*/
protected _maxDigits(): number;
}
export type Chart = import('../types/index.js').Chart;
export type Tick = {
value: number | string;
label?: string;
major?: boolean;
$context?: any;
};
import Element from "./core.element.js";