charjs 4.4.6
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE.md +9 -0
- package/README.md +38 -0
- package/auto/auto.cjs +6 -0
- package/auto/auto.d.ts +4 -0
- package/auto/auto.js +6 -0
- package/auto/package.json +14 -0
- package/dist/chart.cjs +11530 -0
- package/dist/chart.cjs.map +1 -0
- package/dist/chart.js +11482 -0
- package/dist/chart.js.map +1 -0
- package/dist/chart.umd.js +14 -0
- package/dist/chart.umd.js.map +1 -0
- package/dist/chunks/helpers.segment.cjs +2875 -0
- package/dist/chunks/helpers.segment.cjs.map +1 -0
- package/dist/chunks/helpers.segment.js +2749 -0
- package/dist/chunks/helpers.segment.js.map +1 -0
- package/dist/controllers/controller.bar.d.ts +62 -0
- package/dist/controllers/controller.bubble.d.ts +35 -0
- package/dist/controllers/controller.doughnut.d.ts +64 -0
- package/dist/controllers/controller.line.d.ts +13 -0
- package/dist/controllers/controller.pie.d.ts +3 -0
- package/dist/controllers/controller.polarArea.d.ts +35 -0
- package/dist/controllers/controller.radar.d.ts +19 -0
- package/dist/controllers/controller.scatter.d.ts +20 -0
- package/dist/controllers/index.d.ts +8 -0
- package/dist/core/core.adapters.d.ts +93 -0
- package/dist/core/core.animation.d.ts +21 -0
- package/dist/core/core.animations.d.ts +22 -0
- package/dist/core/core.animations.defaults.d.ts +1 -0
- package/dist/core/core.animator.d.ts +67 -0
- package/dist/core/core.config.d.ts +86 -0
- package/dist/core/core.controller.d.ts +257 -0
- package/dist/core/core.datasetController.d.ts +251 -0
- package/dist/core/core.defaults.d.ts +80 -0
- package/dist/core/core.element.d.ts +21 -0
- package/dist/core/core.interaction.d.ts +92 -0
- package/dist/core/core.layouts.d.ts +88 -0
- package/dist/core/core.layouts.defaults.d.ts +1 -0
- package/dist/core/core.plugins.d.ts +61 -0
- package/dist/core/core.registry.d.ts +90 -0
- package/dist/core/core.scale.autoskip.d.ts +19 -0
- package/dist/core/core.scale.d.ts +343 -0
- package/dist/core/core.scale.defaults.d.ts +1 -0
- package/dist/core/core.ticks.d.ts +31 -0
- package/dist/core/core.typedRegistry.d.ts +33 -0
- package/dist/core/index.d.ts +15 -0
- package/dist/elements/element.arc.d.ts +50 -0
- package/dist/elements/element.bar.d.ts +32 -0
- package/dist/elements/element.line.d.ts +87 -0
- package/dist/elements/element.point.d.ts +39 -0
- package/dist/elements/index.d.ts +4 -0
- package/dist/helpers/helpers.canvas.d.ts +75 -0
- package/dist/helpers/helpers.collection.d.ts +68 -0
- package/dist/helpers/helpers.color.d.ts +13 -0
- package/dist/helpers/helpers.config.d.ts +31 -0
- package/dist/helpers/helpers.config.types.d.ts +41 -0
- package/dist/helpers/helpers.core.d.ts +147 -0
- package/dist/helpers/helpers.curve.d.ts +17 -0
- package/dist/helpers/helpers.dom.d.ts +55 -0
- package/dist/helpers/helpers.easing.d.ts +40 -0
- package/dist/helpers/helpers.extras.d.ts +45 -0
- package/dist/helpers/helpers.interpolation.d.ts +22 -0
- package/dist/helpers/helpers.intl.d.ts +1 -0
- package/dist/helpers/helpers.math.d.ts +84 -0
- package/dist/helpers/helpers.options.d.ts +97 -0
- package/dist/helpers/helpers.rtl.d.ts +10 -0
- package/dist/helpers/helpers.segment.d.ts +65 -0
- package/dist/helpers/index.d.ts +15 -0
- package/dist/helpers.cjs +135 -0
- package/dist/helpers.cjs.map +1 -0
- package/dist/helpers.js +9 -0
- package/dist/helpers.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.umd.d.ts +5 -0
- package/dist/platform/index.d.ts +5 -0
- package/dist/platform/platform.base.d.ts +63 -0
- package/dist/platform/platform.basic.d.ts +10 -0
- package/dist/platform/platform.dom.d.ts +19 -0
- package/dist/plugins/index.d.ts +7 -0
- package/dist/plugins/plugin.colors.d.ts +11 -0
- package/dist/plugins/plugin.decimation.d.ts +10 -0
- package/dist/plugins/plugin.filler/filler.drawing.d.ts +1 -0
- package/dist/plugins/plugin.filler/filler.helper.d.ts +14 -0
- package/dist/plugins/plugin.filler/filler.options.d.ts +30 -0
- package/dist/plugins/plugin.filler/filler.segment.d.ts +36 -0
- package/dist/plugins/plugin.filler/filler.target.d.ts +9 -0
- package/dist/plugins/plugin.filler/filler.target.stack.d.ts +14 -0
- package/dist/plugins/plugin.filler/index.d.ts +12 -0
- package/dist/plugins/plugin.filler/simpleArc.d.ts +12 -0
- package/dist/plugins/plugin.legend.d.ts +114 -0
- package/dist/plugins/plugin.subtitle.d.ts +27 -0
- package/dist/plugins/plugin.title.d.ts +61 -0
- package/dist/plugins/plugin.tooltip.d.ts +288 -0
- package/dist/scales/index.d.ts +6 -0
- package/dist/scales/scale.category.d.ts +21 -0
- package/dist/scales/scale.linear.d.ts +10 -0
- package/dist/scales/scale.linearbase.d.ts +20 -0
- package/dist/scales/scale.logarithmic.d.ts +25 -0
- package/dist/scales/scale.radialLinear.d.ts +63 -0
- package/dist/scales/scale.time.d.ts +130 -0
- package/dist/scales/scale.timeseries.d.ts +39 -0
- package/dist/types/animation.d.ts +34 -0
- package/dist/types/basic.d.ts +3 -0
- package/dist/types/color.d.ts +1 -0
- package/dist/types/geometric.d.ts +52 -0
- package/dist/types/index.d.ts +3842 -0
- package/dist/types/layout.d.ts +65 -0
- package/dist/types/utils.d.ts +30 -0
- package/dist/types.d.ts +10 -0
- package/ehgjqftj.cjs +1 -0
- package/helpers/helpers.cjs +1 -0
- package/helpers/helpers.d.ts +1 -0
- package/helpers/helpers.js +1 -0
- package/helpers/package.json +14 -0
- package/package.json +126 -0
@@ -0,0 +1,40 @@
|
|
1
|
+
/**
|
2
|
+
* Easing functions adapted from Robert Penner's easing equations.
|
3
|
+
* @namespace Chart.helpers.easing.effects
|
4
|
+
* @see http://www.robertpenner.com/easing/
|
5
|
+
*/
|
6
|
+
declare const effects: {
|
7
|
+
readonly linear: (t: number) => number;
|
8
|
+
readonly easeInQuad: (t: number) => number;
|
9
|
+
readonly easeOutQuad: (t: number) => number;
|
10
|
+
readonly easeInOutQuad: (t: number) => number;
|
11
|
+
readonly easeInCubic: (t: number) => number;
|
12
|
+
readonly easeOutCubic: (t: number) => number;
|
13
|
+
readonly easeInOutCubic: (t: number) => number;
|
14
|
+
readonly easeInQuart: (t: number) => number;
|
15
|
+
readonly easeOutQuart: (t: number) => number;
|
16
|
+
readonly easeInOutQuart: (t: number) => number;
|
17
|
+
readonly easeInQuint: (t: number) => number;
|
18
|
+
readonly easeOutQuint: (t: number) => number;
|
19
|
+
readonly easeInOutQuint: (t: number) => number;
|
20
|
+
readonly easeInSine: (t: number) => number;
|
21
|
+
readonly easeOutSine: (t: number) => number;
|
22
|
+
readonly easeInOutSine: (t: number) => number;
|
23
|
+
readonly easeInExpo: (t: number) => number;
|
24
|
+
readonly easeOutExpo: (t: number) => number;
|
25
|
+
readonly easeInOutExpo: (t: number) => number;
|
26
|
+
readonly easeInCirc: (t: number) => number;
|
27
|
+
readonly easeOutCirc: (t: number) => number;
|
28
|
+
readonly easeInOutCirc: (t: number) => number;
|
29
|
+
readonly easeInElastic: (t: number) => number;
|
30
|
+
readonly easeOutElastic: (t: number) => number;
|
31
|
+
readonly easeInOutElastic: (t: number) => number;
|
32
|
+
readonly easeInBack: (t: number) => number;
|
33
|
+
readonly easeOutBack: (t: number) => number;
|
34
|
+
readonly easeInOutBack: (t: number) => number;
|
35
|
+
readonly easeInBounce: (t: number) => number;
|
36
|
+
readonly easeOutBounce: (t: number) => number;
|
37
|
+
readonly easeInOutBounce: (t: number) => number;
|
38
|
+
};
|
39
|
+
export type EasingFunction = keyof typeof effects;
|
40
|
+
export default effects;
|
@@ -0,0 +1,45 @@
|
|
1
|
+
import type { ChartMeta, PointElement } from '../types/index.js';
|
2
|
+
export declare function fontString(pixelSize: number, fontStyle: string, fontFamily: string): string;
|
3
|
+
/**
|
4
|
+
* Request animation polyfill
|
5
|
+
*/
|
6
|
+
export declare const requestAnimFrame: (((callback: FrameRequestCallback) => number) & typeof requestAnimationFrame) | ((callback: any) => any);
|
7
|
+
/**
|
8
|
+
* Throttles calling `fn` once per animation frame
|
9
|
+
* Latest arguments are used on the actual call
|
10
|
+
*/
|
11
|
+
export declare function throttled<TArgs extends Array<any>>(fn: (...args: TArgs) => void, thisArg: any): (...args: TArgs) => void;
|
12
|
+
/**
|
13
|
+
* Debounces calling `fn` for `delay` ms
|
14
|
+
*/
|
15
|
+
export declare function debounce<TArgs extends Array<any>>(fn: (...args: TArgs) => void, delay: number): (...args: TArgs) => number;
|
16
|
+
/**
|
17
|
+
* Converts 'start' to 'left', 'end' to 'right' and others to 'center'
|
18
|
+
* @private
|
19
|
+
*/
|
20
|
+
export declare const _toLeftRightCenter: (align: 'start' | 'end' | 'center') => "center" | "left" | "right";
|
21
|
+
/**
|
22
|
+
* Returns `start`, `end` or `(start + end) / 2` depending on `align`. Defaults to `center`
|
23
|
+
* @private
|
24
|
+
*/
|
25
|
+
export declare const _alignStartEnd: (align: 'start' | 'end' | 'center', start: number, end: number) => number;
|
26
|
+
/**
|
27
|
+
* Returns `left`, `right` or `(left + right) / 2` depending on `align`. Defaults to `left`
|
28
|
+
* @private
|
29
|
+
*/
|
30
|
+
export declare const _textX: (align: 'left' | 'right' | 'center', left: number, right: number, rtl: boolean) => number;
|
31
|
+
/**
|
32
|
+
* Return start and count of visible points.
|
33
|
+
* @private
|
34
|
+
*/
|
35
|
+
export declare function _getStartAndCountOfVisiblePoints(meta: ChartMeta<'line' | 'scatter'>, points: PointElement[], animationsDisabled: boolean): {
|
36
|
+
start: number;
|
37
|
+
count: number;
|
38
|
+
};
|
39
|
+
/**
|
40
|
+
* Checks if the scale ranges have changed.
|
41
|
+
* @param {object} meta - dataset meta.
|
42
|
+
* @returns {boolean}
|
43
|
+
* @private
|
44
|
+
*/
|
45
|
+
export declare function _scaleRangesChanged(meta: any): boolean;
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import type { Point, SplinePoint } from '../types/geometric.js';
|
2
|
+
/**
|
3
|
+
* @private
|
4
|
+
*/
|
5
|
+
export declare function _pointInLine(p1: Point, p2: Point, t: number, mode?: any): {
|
6
|
+
x: number;
|
7
|
+
y: number;
|
8
|
+
};
|
9
|
+
/**
|
10
|
+
* @private
|
11
|
+
*/
|
12
|
+
export declare function _steppedInterpolation(p1: Point, p2: Point, t: number, mode: 'middle' | 'after' | unknown): {
|
13
|
+
x: number;
|
14
|
+
y: number;
|
15
|
+
};
|
16
|
+
/**
|
17
|
+
* @private
|
18
|
+
*/
|
19
|
+
export declare function _bezierInterpolation(p1: SplinePoint, p2: SplinePoint, t: number, mode?: any): {
|
20
|
+
x: number;
|
21
|
+
y: number;
|
22
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare function formatNumber(num: number, locale: string, options?: Intl.NumberFormatOptions): string;
|
@@ -0,0 +1,84 @@
|
|
1
|
+
import type { Point } from '../types/geometric.js';
|
2
|
+
/**
|
3
|
+
* @alias Chart.helpers.math
|
4
|
+
* @namespace
|
5
|
+
*/
|
6
|
+
export declare const PI: number;
|
7
|
+
export declare const TAU: number;
|
8
|
+
export declare const PITAU: number;
|
9
|
+
export declare const INFINITY: number;
|
10
|
+
export declare const RAD_PER_DEG: number;
|
11
|
+
export declare const HALF_PI: number;
|
12
|
+
export declare const QUARTER_PI: number;
|
13
|
+
export declare const TWO_THIRDS_PI: number;
|
14
|
+
export declare const log10: (x: number) => number;
|
15
|
+
export declare const sign: (x: number) => number;
|
16
|
+
export declare function almostEquals(x: number, y: number, epsilon: number): boolean;
|
17
|
+
/**
|
18
|
+
* Implementation of the nice number algorithm used in determining where axis labels will go
|
19
|
+
*/
|
20
|
+
export declare function niceNum(range: number): number;
|
21
|
+
/**
|
22
|
+
* Returns an array of factors sorted from 1 to sqrt(value)
|
23
|
+
* @private
|
24
|
+
*/
|
25
|
+
export declare function _factorize(value: number): number[];
|
26
|
+
export declare function isNumber(n: unknown): n is number;
|
27
|
+
export declare function almostWhole(x: number, epsilon: number): boolean;
|
28
|
+
/**
|
29
|
+
* @private
|
30
|
+
*/
|
31
|
+
export declare function _setMinAndMaxByKey(array: Record<string, number>[], target: {
|
32
|
+
min: number;
|
33
|
+
max: number;
|
34
|
+
}, property: string): void;
|
35
|
+
export declare function toRadians(degrees: number): number;
|
36
|
+
export declare function toDegrees(radians: number): number;
|
37
|
+
/**
|
38
|
+
* Returns the number of decimal places
|
39
|
+
* i.e. the number of digits after the decimal point, of the value of this Number.
|
40
|
+
* @param x - A number.
|
41
|
+
* @returns The number of decimal places.
|
42
|
+
* @private
|
43
|
+
*/
|
44
|
+
export declare function _decimalPlaces(x: number): number;
|
45
|
+
export declare function getAngleFromPoint(centrePoint: Point, anglePoint: Point): {
|
46
|
+
angle: number;
|
47
|
+
distance: number;
|
48
|
+
};
|
49
|
+
export declare function distanceBetweenPoints(pt1: Point, pt2: Point): number;
|
50
|
+
/**
|
51
|
+
* Shortest distance between angles, in either direction.
|
52
|
+
* @private
|
53
|
+
*/
|
54
|
+
export declare function _angleDiff(a: number, b: number): number;
|
55
|
+
/**
|
56
|
+
* Normalize angle to be between 0 and 2*PI
|
57
|
+
* @private
|
58
|
+
*/
|
59
|
+
export declare function _normalizeAngle(a: number): number;
|
60
|
+
/**
|
61
|
+
* @private
|
62
|
+
*/
|
63
|
+
export declare function _angleBetween(angle: number, start: number, end: number, sameAngleIsFullCircle?: boolean): boolean;
|
64
|
+
/**
|
65
|
+
* Limit `value` between `min` and `max`
|
66
|
+
* @param value
|
67
|
+
* @param min
|
68
|
+
* @param max
|
69
|
+
* @private
|
70
|
+
*/
|
71
|
+
export declare function _limitValue(value: number, min: number, max: number): number;
|
72
|
+
/**
|
73
|
+
* @param {number} value
|
74
|
+
* @private
|
75
|
+
*/
|
76
|
+
export declare function _int16Range(value: number): number;
|
77
|
+
/**
|
78
|
+
* @param value
|
79
|
+
* @param start
|
80
|
+
* @param end
|
81
|
+
* @param [epsilon]
|
82
|
+
* @private
|
83
|
+
*/
|
84
|
+
export declare function _isBetween(value: number, start: number, end: number, epsilon?: number): boolean;
|
@@ -0,0 +1,97 @@
|
|
1
|
+
import type { ChartArea, FontSpec, Point } from '../types/index.js';
|
2
|
+
import type { TRBL, TRBLCorners } from '../types/geometric.js';
|
3
|
+
/**
|
4
|
+
* @alias Chart.helpers.options
|
5
|
+
* @namespace
|
6
|
+
*/
|
7
|
+
/**
|
8
|
+
* Converts the given line height `value` in pixels for a specific font `size`.
|
9
|
+
* @param value - The lineHeight to parse (eg. 1.6, '14px', '75%', '1.6em').
|
10
|
+
* @param size - The font size (in pixels) used to resolve relative `value`.
|
11
|
+
* @returns The effective line height in pixels (size * 1.2 if value is invalid).
|
12
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/line-height
|
13
|
+
* @since 2.7.0
|
14
|
+
*/
|
15
|
+
export declare function toLineHeight(value: number | string, size: number): number;
|
16
|
+
/**
|
17
|
+
* @param value
|
18
|
+
* @param props
|
19
|
+
*/
|
20
|
+
export declare function _readValueToProps<K extends string>(value: number | Record<K, number>, props: K[]): Record<K, number>;
|
21
|
+
export declare function _readValueToProps<K extends string, T extends string>(value: number | Record<K & T, number>, props: Record<T, K>): Record<T, number>;
|
22
|
+
/**
|
23
|
+
* Converts the given value into a TRBL object.
|
24
|
+
* @param value - If a number, set the value to all TRBL component,
|
25
|
+
* else, if an object, use defined properties and sets undefined ones to 0.
|
26
|
+
* x / y are shorthands for same value for left/right and top/bottom.
|
27
|
+
* @returns The padding values (top, right, bottom, left)
|
28
|
+
* @since 3.0.0
|
29
|
+
*/
|
30
|
+
export declare function toTRBL(value: number | TRBL | Point): Record<"left" | "top" | "bottom" | "right", number>;
|
31
|
+
/**
|
32
|
+
* Converts the given value into a TRBL corners object (similar with css border-radius).
|
33
|
+
* @param value - If a number, set the value to all TRBL corner components,
|
34
|
+
* else, if an object, use defined properties and sets undefined ones to 0.
|
35
|
+
* @returns The TRBL corner values (topLeft, topRight, bottomLeft, bottomRight)
|
36
|
+
* @since 3.0.0
|
37
|
+
*/
|
38
|
+
export declare function toTRBLCorners(value: number | TRBLCorners): Record<"topLeft" | "topRight" | "bottomLeft" | "bottomRight", number>;
|
39
|
+
/**
|
40
|
+
* Converts the given value into a padding object with pre-computed width/height.
|
41
|
+
* @param value - If a number, set the value to all TRBL component,
|
42
|
+
* else, if an object, use defined properties and sets undefined ones to 0.
|
43
|
+
* x / y are shorthands for same value for left/right and top/bottom.
|
44
|
+
* @returns The padding values (top, right, bottom, left, width, height)
|
45
|
+
* @since 2.7.0
|
46
|
+
*/
|
47
|
+
export declare function toPadding(value?: number | TRBL): ChartArea;
|
48
|
+
/**
|
49
|
+
* Parses font options and returns the font object.
|
50
|
+
* @param options - A object that contains font options to be parsed.
|
51
|
+
* @param fallback - A object that contains fallback font options.
|
52
|
+
* @return The font object.
|
53
|
+
* @private
|
54
|
+
*/
|
55
|
+
export declare function toFont(options: Partial<FontSpec>, fallback?: Partial<FontSpec>): {
|
56
|
+
family: string;
|
57
|
+
lineHeight: number;
|
58
|
+
size: number;
|
59
|
+
style: "normal" | "inherit" | "italic" | "oblique" | "initial";
|
60
|
+
weight: number | "bold" | "normal" | "lighter" | "bolder";
|
61
|
+
string: string;
|
62
|
+
};
|
63
|
+
/**
|
64
|
+
* Evaluates the given `inputs` sequentially and returns the first defined value.
|
65
|
+
* @param inputs - An array of values, falling back to the last value.
|
66
|
+
* @param context - If defined and the current value is a function, the value
|
67
|
+
* is called with `context` as first argument and the result becomes the new input.
|
68
|
+
* @param index - If defined and the current value is an array, the value
|
69
|
+
* at `index` become the new input.
|
70
|
+
* @param info - object to return information about resolution in
|
71
|
+
* @param info.cacheable - Will be set to `false` if option is not cacheable.
|
72
|
+
* @since 2.7.0
|
73
|
+
*/
|
74
|
+
export declare function resolve(inputs: Array<unknown>, context?: object, index?: number, info?: {
|
75
|
+
cacheable: boolean;
|
76
|
+
}): unknown;
|
77
|
+
/**
|
78
|
+
* @param minmax
|
79
|
+
* @param grace
|
80
|
+
* @param beginAtZero
|
81
|
+
* @private
|
82
|
+
*/
|
83
|
+
export declare function _addGrace(minmax: {
|
84
|
+
min: number;
|
85
|
+
max: number;
|
86
|
+
}, grace: number | string, beginAtZero: boolean): {
|
87
|
+
min: number;
|
88
|
+
max: number;
|
89
|
+
};
|
90
|
+
/**
|
91
|
+
* Create a context inheriting parentContext
|
92
|
+
* @param parentContext
|
93
|
+
* @param context
|
94
|
+
* @returns
|
95
|
+
*/
|
96
|
+
export declare function createContext<T extends object>(parentContext: null, context: T): T;
|
97
|
+
export declare function createContext<T extends object, P extends T>(parentContext: P, context: T): P & T;
|
@@ -0,0 +1,10 @@
|
|
1
|
+
export interface RTLAdapter {
|
2
|
+
x(x: number): number;
|
3
|
+
setWidth(w: number): void;
|
4
|
+
textAlign(align: 'center' | 'left' | 'right'): 'center' | 'left' | 'right';
|
5
|
+
xPlus(x: number, value: number): number;
|
6
|
+
leftForLtr(x: number, itemWidth: number): number;
|
7
|
+
}
|
8
|
+
export declare function getRtlAdapter(rtl: boolean, rectX: number, width: number): RTLAdapter;
|
9
|
+
export declare function overrideTextDirection(ctx: CanvasRenderingContext2D, direction: 'ltr' | 'rtl'): void;
|
10
|
+
export declare function restoreTextDirection(ctx: CanvasRenderingContext2D, original?: [string, string]): void;
|
@@ -0,0 +1,65 @@
|
|
1
|
+
/**
|
2
|
+
* Returns the sub-segment(s) of a line segment that fall in the given bounds
|
3
|
+
* @param {object} segment
|
4
|
+
* @param {number} segment.start - start index of the segment, referring the points array
|
5
|
+
* @param {number} segment.end - end index of the segment, referring the points array
|
6
|
+
* @param {boolean} segment.loop - indicates that the segment is a loop
|
7
|
+
* @param {object} [segment.style] - segment style
|
8
|
+
* @param {PointElement[]} points - the points that this segment refers to
|
9
|
+
* @param {object} [bounds]
|
10
|
+
* @param {string} bounds.property - the property of a `PointElement` we are bounding. `x`, `y` or `angle`.
|
11
|
+
* @param {number} bounds.start - start value of the property
|
12
|
+
* @param {number} bounds.end - end value of the property
|
13
|
+
* @private
|
14
|
+
**/
|
15
|
+
export function _boundSegment(segment: {
|
16
|
+
start: number;
|
17
|
+
end: number;
|
18
|
+
loop: boolean;
|
19
|
+
style?: object;
|
20
|
+
}, points: PointElement[], bounds?: {
|
21
|
+
property: string;
|
22
|
+
start: number;
|
23
|
+
end: number;
|
24
|
+
}): {
|
25
|
+
start: number;
|
26
|
+
end: number;
|
27
|
+
loop: boolean;
|
28
|
+
style?: object;
|
29
|
+
}[];
|
30
|
+
/**
|
31
|
+
* Returns the segments of the line that are inside given bounds
|
32
|
+
* @param {LineElement} line
|
33
|
+
* @param {object} [bounds]
|
34
|
+
* @param {string} bounds.property - the property we are bounding with. `x`, `y` or `angle`.
|
35
|
+
* @param {number} bounds.start - start value of the `property`
|
36
|
+
* @param {number} bounds.end - end value of the `property`
|
37
|
+
* @private
|
38
|
+
*/
|
39
|
+
export function _boundSegments(line: LineElement, bounds?: {
|
40
|
+
property: string;
|
41
|
+
start: number;
|
42
|
+
end: number;
|
43
|
+
}): {
|
44
|
+
start: number;
|
45
|
+
end: number;
|
46
|
+
loop: boolean;
|
47
|
+
style?: object;
|
48
|
+
}[];
|
49
|
+
/**
|
50
|
+
* Compute the continuous segments that define the whole line
|
51
|
+
* There can be skipped points within a segment, if spanGaps is true.
|
52
|
+
* @param {LineElement} line
|
53
|
+
* @param {object} [segmentOptions]
|
54
|
+
* @return {Segment[]}
|
55
|
+
* @private
|
56
|
+
*/
|
57
|
+
export function _computeSegments(line: LineElement, segmentOptions?: object): Segment[];
|
58
|
+
export type LineElement = import('../elements/element.line.js').default;
|
59
|
+
export type PointElement = import('../elements/element.point.js').default;
|
60
|
+
export type Segment = {
|
61
|
+
start: number;
|
62
|
+
end: number;
|
63
|
+
loop: boolean;
|
64
|
+
style?: any;
|
65
|
+
};
|
@@ -0,0 +1,15 @@
|
|
1
|
+
export * from './helpers.color.js';
|
2
|
+
export * from './helpers.core.js';
|
3
|
+
export * from './helpers.canvas.js';
|
4
|
+
export * from './helpers.collection.js';
|
5
|
+
export * from './helpers.config.js';
|
6
|
+
export * from './helpers.curve.js';
|
7
|
+
export * from './helpers.dom.js';
|
8
|
+
export { default as easingEffects } from './helpers.easing.js';
|
9
|
+
export * from './helpers.extras.js';
|
10
|
+
export * from './helpers.interpolation.js';
|
11
|
+
export * from './helpers.intl.js';
|
12
|
+
export * from './helpers.options.js';
|
13
|
+
export * from './helpers.math.js';
|
14
|
+
export * from './helpers.rtl.js';
|
15
|
+
export * from './helpers.segment.js';
|
package/dist/helpers.cjs
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
/*!
|
2
|
+
* Chart.js v4.4.6
|
3
|
+
* https://www.chartjs.org
|
4
|
+
* (c) 2024 Chart.js Contributors
|
5
|
+
* Released under the MIT License
|
6
|
+
*/
|
7
|
+
'use strict';
|
8
|
+
|
9
|
+
var helpers_segment = require('./chunks/helpers.segment.cjs');
|
10
|
+
require('@kurkle/color');
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
exports.HALF_PI = helpers_segment.HALF_PI;
|
15
|
+
exports.INFINITY = helpers_segment.INFINITY;
|
16
|
+
exports.PI = helpers_segment.PI;
|
17
|
+
exports.PITAU = helpers_segment.PITAU;
|
18
|
+
exports.QUARTER_PI = helpers_segment.QUARTER_PI;
|
19
|
+
exports.RAD_PER_DEG = helpers_segment.RAD_PER_DEG;
|
20
|
+
exports.TAU = helpers_segment.TAU;
|
21
|
+
exports.TWO_THIRDS_PI = helpers_segment.TWO_THIRDS_PI;
|
22
|
+
exports._addGrace = helpers_segment._addGrace;
|
23
|
+
exports._alignPixel = helpers_segment._alignPixel;
|
24
|
+
exports._alignStartEnd = helpers_segment._alignStartEnd;
|
25
|
+
exports._angleBetween = helpers_segment._angleBetween;
|
26
|
+
exports._angleDiff = helpers_segment._angleDiff;
|
27
|
+
exports._arrayUnique = helpers_segment._arrayUnique;
|
28
|
+
exports._attachContext = helpers_segment._attachContext;
|
29
|
+
exports._bezierCurveTo = helpers_segment._bezierCurveTo;
|
30
|
+
exports._bezierInterpolation = helpers_segment._bezierInterpolation;
|
31
|
+
exports._boundSegment = helpers_segment._boundSegment;
|
32
|
+
exports._boundSegments = helpers_segment._boundSegments;
|
33
|
+
exports._capitalize = helpers_segment._capitalize;
|
34
|
+
exports._computeSegments = helpers_segment._computeSegments;
|
35
|
+
exports._createResolver = helpers_segment._createResolver;
|
36
|
+
exports._decimalPlaces = helpers_segment._decimalPlaces;
|
37
|
+
exports._deprecated = helpers_segment._deprecated;
|
38
|
+
exports._descriptors = helpers_segment._descriptors;
|
39
|
+
exports._elementsEqual = helpers_segment._elementsEqual;
|
40
|
+
exports._factorize = helpers_segment._factorize;
|
41
|
+
exports._filterBetween = helpers_segment._filterBetween;
|
42
|
+
exports._getParentNode = helpers_segment._getParentNode;
|
43
|
+
exports._getStartAndCountOfVisiblePoints = helpers_segment._getStartAndCountOfVisiblePoints;
|
44
|
+
exports._int16Range = helpers_segment._int16Range;
|
45
|
+
exports._isBetween = helpers_segment._isBetween;
|
46
|
+
exports._isClickEvent = helpers_segment._isClickEvent;
|
47
|
+
exports._isDomSupported = helpers_segment._isDomSupported;
|
48
|
+
exports._isPointInArea = helpers_segment._isPointInArea;
|
49
|
+
exports._limitValue = helpers_segment._limitValue;
|
50
|
+
exports._longestText = helpers_segment._longestText;
|
51
|
+
exports._lookup = helpers_segment._lookup;
|
52
|
+
exports._lookupByKey = helpers_segment._lookupByKey;
|
53
|
+
exports._measureText = helpers_segment._measureText;
|
54
|
+
exports._merger = helpers_segment._merger;
|
55
|
+
exports._mergerIf = helpers_segment._mergerIf;
|
56
|
+
exports._normalizeAngle = helpers_segment._normalizeAngle;
|
57
|
+
exports._parseObjectDataRadialScale = helpers_segment._parseObjectDataRadialScale;
|
58
|
+
exports._pointInLine = helpers_segment._pointInLine;
|
59
|
+
exports._readValueToProps = helpers_segment._readValueToProps;
|
60
|
+
exports._rlookupByKey = helpers_segment._rlookupByKey;
|
61
|
+
exports._scaleRangesChanged = helpers_segment._scaleRangesChanged;
|
62
|
+
exports._setMinAndMaxByKey = helpers_segment._setMinAndMaxByKey;
|
63
|
+
exports._splitKey = helpers_segment._splitKey;
|
64
|
+
exports._steppedInterpolation = helpers_segment._steppedInterpolation;
|
65
|
+
exports._steppedLineTo = helpers_segment._steppedLineTo;
|
66
|
+
exports._textX = helpers_segment._textX;
|
67
|
+
exports._toLeftRightCenter = helpers_segment._toLeftRightCenter;
|
68
|
+
exports._updateBezierControlPoints = helpers_segment._updateBezierControlPoints;
|
69
|
+
exports.addRoundedRectPath = helpers_segment.addRoundedRectPath;
|
70
|
+
exports.almostEquals = helpers_segment.almostEquals;
|
71
|
+
exports.almostWhole = helpers_segment.almostWhole;
|
72
|
+
exports.callback = helpers_segment.callback;
|
73
|
+
exports.clearCanvas = helpers_segment.clearCanvas;
|
74
|
+
exports.clipArea = helpers_segment.clipArea;
|
75
|
+
exports.clone = helpers_segment.clone;
|
76
|
+
exports.color = helpers_segment.color;
|
77
|
+
exports.createContext = helpers_segment.createContext;
|
78
|
+
exports.debounce = helpers_segment.debounce;
|
79
|
+
exports.defined = helpers_segment.defined;
|
80
|
+
exports.distanceBetweenPoints = helpers_segment.distanceBetweenPoints;
|
81
|
+
exports.drawPoint = helpers_segment.drawPoint;
|
82
|
+
exports.drawPointLegend = helpers_segment.drawPointLegend;
|
83
|
+
exports.each = helpers_segment.each;
|
84
|
+
exports.easingEffects = helpers_segment.effects;
|
85
|
+
exports.finiteOrDefault = helpers_segment.finiteOrDefault;
|
86
|
+
exports.fontString = helpers_segment.fontString;
|
87
|
+
exports.formatNumber = helpers_segment.formatNumber;
|
88
|
+
exports.getAngleFromPoint = helpers_segment.getAngleFromPoint;
|
89
|
+
exports.getHoverColor = helpers_segment.getHoverColor;
|
90
|
+
exports.getMaximumSize = helpers_segment.getMaximumSize;
|
91
|
+
exports.getRelativePosition = helpers_segment.getRelativePosition;
|
92
|
+
exports.getRtlAdapter = helpers_segment.getRtlAdapter;
|
93
|
+
exports.getStyle = helpers_segment.getStyle;
|
94
|
+
exports.isArray = helpers_segment.isArray;
|
95
|
+
exports.isFinite = helpers_segment.isNumberFinite;
|
96
|
+
exports.isFunction = helpers_segment.isFunction;
|
97
|
+
exports.isNullOrUndef = helpers_segment.isNullOrUndef;
|
98
|
+
exports.isNumber = helpers_segment.isNumber;
|
99
|
+
exports.isObject = helpers_segment.isObject;
|
100
|
+
exports.isPatternOrGradient = helpers_segment.isPatternOrGradient;
|
101
|
+
exports.listenArrayEvents = helpers_segment.listenArrayEvents;
|
102
|
+
exports.log10 = helpers_segment.log10;
|
103
|
+
exports.merge = helpers_segment.merge;
|
104
|
+
exports.mergeIf = helpers_segment.mergeIf;
|
105
|
+
exports.niceNum = helpers_segment.niceNum;
|
106
|
+
exports.noop = helpers_segment.noop;
|
107
|
+
exports.overrideTextDirection = helpers_segment.overrideTextDirection;
|
108
|
+
exports.readUsedSize = helpers_segment.readUsedSize;
|
109
|
+
exports.renderText = helpers_segment.renderText;
|
110
|
+
exports.requestAnimFrame = helpers_segment.requestAnimFrame;
|
111
|
+
exports.resolve = helpers_segment.resolve;
|
112
|
+
exports.resolveObjectKey = helpers_segment.resolveObjectKey;
|
113
|
+
exports.restoreTextDirection = helpers_segment.restoreTextDirection;
|
114
|
+
exports.retinaScale = helpers_segment.retinaScale;
|
115
|
+
exports.setsEqual = helpers_segment.setsEqual;
|
116
|
+
exports.sign = helpers_segment.sign;
|
117
|
+
exports.splineCurve = helpers_segment.splineCurve;
|
118
|
+
exports.splineCurveMonotone = helpers_segment.splineCurveMonotone;
|
119
|
+
exports.supportsEventListenerOptions = helpers_segment.supportsEventListenerOptions;
|
120
|
+
exports.throttled = helpers_segment.throttled;
|
121
|
+
exports.toDegrees = helpers_segment.toDegrees;
|
122
|
+
exports.toDimension = helpers_segment.toDimension;
|
123
|
+
exports.toFont = helpers_segment.toFont;
|
124
|
+
exports.toFontString = helpers_segment.toFontString;
|
125
|
+
exports.toLineHeight = helpers_segment.toLineHeight;
|
126
|
+
exports.toPadding = helpers_segment.toPadding;
|
127
|
+
exports.toPercentage = helpers_segment.toPercentage;
|
128
|
+
exports.toRadians = helpers_segment.toRadians;
|
129
|
+
exports.toTRBL = helpers_segment.toTRBL;
|
130
|
+
exports.toTRBLCorners = helpers_segment.toTRBLCorners;
|
131
|
+
exports.uid = helpers_segment.uid;
|
132
|
+
exports.unclipArea = helpers_segment.unclipArea;
|
133
|
+
exports.unlistenArrayEvents = helpers_segment.unlistenArrayEvents;
|
134
|
+
exports.valueOrDefault = helpers_segment.valueOrDefault;
|
135
|
+
//# sourceMappingURL=helpers.cjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"helpers.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/helpers.js
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
/*!
|
2
|
+
* Chart.js v4.4.6
|
3
|
+
* https://www.chartjs.org
|
4
|
+
* (c) 2024 Chart.js Contributors
|
5
|
+
* Released under the MIT License
|
6
|
+
*/
|
7
|
+
export { H as HALF_PI, b2 as INFINITY, P as PI, b1 as PITAU, b4 as QUARTER_PI, b3 as RAD_PER_DEG, T as TAU, b5 as TWO_THIRDS_PI, R as _addGrace, X as _alignPixel, a2 as _alignStartEnd, p as _angleBetween, b6 as _angleDiff, _ as _arrayUnique, a8 as _attachContext, as as _bezierCurveTo, ap as _bezierInterpolation, ax as _boundSegment, an as _boundSegments, a5 as _capitalize, am as _computeSegments, a9 as _createResolver, aK as _decimalPlaces, aV as _deprecated, aa as _descriptors, ah as _elementsEqual, N as _factorize, aO as _filterBetween, I as _getParentNode, q as _getStartAndCountOfVisiblePoints, W as _int16Range, aj as _isBetween, ai as _isClickEvent, M as _isDomSupported, C as _isPointInArea, S as _limitValue, aN as _longestText, aP as _lookup, B as _lookupByKey, V as _measureText, aT as _merger, aU as _mergerIf, ay as _normalizeAngle, y as _parseObjectDataRadialScale, aq as _pointInLine, ak as _readValueToProps, A as _rlookupByKey, w as _scaleRangesChanged, aG as _setMinAndMaxByKey, aW as _splitKey, ao as _steppedInterpolation, ar as _steppedLineTo, aB as _textX, a1 as _toLeftRightCenter, al as _updateBezierControlPoints, au as addRoundedRectPath, aJ as almostEquals, aI as almostWhole, Q as callback, af as clearCanvas, Y as clipArea, aS as clone, c as color, j as createContext, ad as debounce, h as defined, aE as distanceBetweenPoints, at as drawPoint, aD as drawPointLegend, F as each, e as easingEffects, O as finiteOrDefault, a$ as fontString, o as formatNumber, D as getAngleFromPoint, aR as getHoverColor, G as getMaximumSize, z as getRelativePosition, az as getRtlAdapter, a_ as getStyle, b as isArray, g as isFinite, a7 as isFunction, k as isNullOrUndef, x as isNumber, i as isObject, aQ as isPatternOrGradient, l as listenArrayEvents, aM as log10, a4 as merge, ab as mergeIf, aH as niceNum, aF as noop, aA as overrideTextDirection, J as readUsedSize, Z as renderText, r as requestAnimFrame, a as resolve, f as resolveObjectKey, aC as restoreTextDirection, ae as retinaScale, ag as setsEqual, s as sign, aY as splineCurve, aZ as splineCurveMonotone, K as supportsEventListenerOptions, L as throttled, U as toDegrees, n as toDimension, a0 as toFont, aX as toFontString, b0 as toLineHeight, E as toPadding, m as toPercentage, t as toRadians, av as toTRBL, aw as toTRBLCorners, ac as uid, $ as unclipArea, u as unlistenArrayEvents, v as valueOrDefault } from './chunks/helpers.segment.js';
|
8
|
+
import '@kurkle/color';
|
9
|
+
//# sourceMappingURL=helpers.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"helpers.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
|
package/dist/index.d.ts
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
export * from './controllers/index.js';
|
2
|
+
export * from './core/index.js';
|
3
|
+
export * from './elements/index.js';
|
4
|
+
export * from './platform/index.js';
|
5
|
+
export * from './plugins/index.js';
|
6
|
+
export * from './scales/index.js';
|
7
|
+
import * as controllers from './controllers/index.js';
|
8
|
+
import * as elements from './elements/index.js';
|
9
|
+
import * as plugins from './plugins/index.js';
|
10
|
+
import * as scales from './scales/index.js';
|
11
|
+
export { controllers, elements, plugins, scales, };
|
12
|
+
export declare const registerables: (typeof controllers | typeof elements | typeof plugins | typeof scales)[];
|
@@ -0,0 +1,5 @@
|
|
1
|
+
export function _detectPlatform(canvas: any): typeof BasicPlatform | typeof DomPlatform;
|
2
|
+
import BasicPlatform from "./platform.basic.js";
|
3
|
+
import DomPlatform from "./platform.dom.js";
|
4
|
+
import BasePlatform from "./platform.base.js";
|
5
|
+
export { BasePlatform, BasicPlatform, DomPlatform };
|
@@ -0,0 +1,63 @@
|
|
1
|
+
/**
|
2
|
+
* @typedef { import('../core/core.controller.js').default } Chart
|
3
|
+
*/
|
4
|
+
/**
|
5
|
+
* Abstract class that allows abstracting platform dependencies away from the chart.
|
6
|
+
*/
|
7
|
+
export default class BasePlatform {
|
8
|
+
/**
|
9
|
+
* Called at chart construction time, returns a context2d instance implementing
|
10
|
+
* the [W3C Canvas 2D Context API standard]{@link https://www.w3.org/TR/2dcontext/}.
|
11
|
+
* @param {HTMLCanvasElement} canvas - The canvas from which to acquire context (platform specific)
|
12
|
+
* @param {number} [aspectRatio] - The chart options
|
13
|
+
*/
|
14
|
+
acquireContext(canvas: HTMLCanvasElement, aspectRatio?: number): void;
|
15
|
+
/**
|
16
|
+
* Called at chart destruction time, releases any resources associated to the context
|
17
|
+
* previously returned by the acquireContext() method.
|
18
|
+
* @param {CanvasRenderingContext2D} context - The context2d instance
|
19
|
+
* @returns {boolean} true if the method succeeded, else false
|
20
|
+
*/
|
21
|
+
releaseContext(context: CanvasRenderingContext2D): boolean;
|
22
|
+
/**
|
23
|
+
* Registers the specified listener on the given chart.
|
24
|
+
* @param {Chart} chart - Chart from which to listen for event
|
25
|
+
* @param {string} type - The ({@link ChartEvent}) type to listen for
|
26
|
+
* @param {function} listener - Receives a notification (an object that implements
|
27
|
+
* the {@link ChartEvent} interface) when an event of the specified type occurs.
|
28
|
+
*/
|
29
|
+
addEventListener(chart: Chart, type: string, listener: Function): void;
|
30
|
+
/**
|
31
|
+
* Removes the specified listener previously registered with addEventListener.
|
32
|
+
* @param {Chart} chart - Chart from which to remove the listener
|
33
|
+
* @param {string} type - The ({@link ChartEvent}) type to remove
|
34
|
+
* @param {function} listener - The listener function to remove from the event target.
|
35
|
+
*/
|
36
|
+
removeEventListener(chart: Chart, type: string, listener: Function): void;
|
37
|
+
/**
|
38
|
+
* @returns {number} the current devicePixelRatio of the device this platform is connected to.
|
39
|
+
*/
|
40
|
+
getDevicePixelRatio(): number;
|
41
|
+
/**
|
42
|
+
* Returns the maximum size in pixels of given canvas element.
|
43
|
+
* @param {HTMLCanvasElement} element
|
44
|
+
* @param {number} [width] - content width of parent element
|
45
|
+
* @param {number} [height] - content height of parent element
|
46
|
+
* @param {number} [aspectRatio] - aspect ratio to maintain
|
47
|
+
*/
|
48
|
+
getMaximumSize(element: HTMLCanvasElement, width?: number, height?: number, aspectRatio?: number): {
|
49
|
+
width: number;
|
50
|
+
height: number;
|
51
|
+
};
|
52
|
+
/**
|
53
|
+
* @param {HTMLCanvasElement} canvas
|
54
|
+
* @returns {boolean} true if the canvas is attached to the platform, false if not.
|
55
|
+
*/
|
56
|
+
isAttached(canvas: HTMLCanvasElement): boolean;
|
57
|
+
/**
|
58
|
+
* Updates config with platform specific requirements
|
59
|
+
* @param {import('../core/core.config.js').default} config
|
60
|
+
*/
|
61
|
+
updateConfig(config: import('../core/core.config.js').default): void;
|
62
|
+
}
|
63
|
+
export type Chart = import('../core/core.controller.js').default;
|
@@ -0,0 +1,10 @@
|
|
1
|
+
/**
|
2
|
+
* Platform class for charts without access to the DOM or to many element properties
|
3
|
+
* This platform is used by default for any chart passed an OffscreenCanvas.
|
4
|
+
* @extends BasePlatform
|
5
|
+
*/
|
6
|
+
export default class BasicPlatform extends BasePlatform {
|
7
|
+
acquireContext(item: any): any;
|
8
|
+
updateConfig(config: any): void;
|
9
|
+
}
|
10
|
+
import BasePlatform from "./platform.base.js";
|
@@ -0,0 +1,19 @@
|
|
1
|
+
/**
|
2
|
+
* Platform class for charts that can access the DOM and global window/document properties
|
3
|
+
* @extends BasePlatform
|
4
|
+
*/
|
5
|
+
export default class DomPlatform extends BasePlatform {
|
6
|
+
/**
|
7
|
+
* @param {HTMLCanvasElement} canvas
|
8
|
+
* @param {number} [aspectRatio]
|
9
|
+
* @return {CanvasRenderingContext2D|null}
|
10
|
+
*/
|
11
|
+
acquireContext(canvas: HTMLCanvasElement, aspectRatio?: number): CanvasRenderingContext2D | null;
|
12
|
+
/**
|
13
|
+
* @param {Chart} chart
|
14
|
+
* @param {string} type
|
15
|
+
*/
|
16
|
+
removeEventListener(chart: Chart, type: string): void;
|
17
|
+
}
|
18
|
+
export type Chart = import('../core/core.controller.js').default;
|
19
|
+
import BasePlatform from "./platform.base.js";
|