charjs 4.4.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. package/LICENSE.md +9 -0
  2. package/README.md +38 -0
  3. package/auto/auto.cjs +6 -0
  4. package/auto/auto.d.ts +4 -0
  5. package/auto/auto.js +6 -0
  6. package/auto/package.json +14 -0
  7. package/dist/chart.cjs +11530 -0
  8. package/dist/chart.cjs.map +1 -0
  9. package/dist/chart.js +11482 -0
  10. package/dist/chart.js.map +1 -0
  11. package/dist/chart.umd.js +14 -0
  12. package/dist/chart.umd.js.map +1 -0
  13. package/dist/chunks/helpers.segment.cjs +2875 -0
  14. package/dist/chunks/helpers.segment.cjs.map +1 -0
  15. package/dist/chunks/helpers.segment.js +2749 -0
  16. package/dist/chunks/helpers.segment.js.map +1 -0
  17. package/dist/controllers/controller.bar.d.ts +62 -0
  18. package/dist/controllers/controller.bubble.d.ts +35 -0
  19. package/dist/controllers/controller.doughnut.d.ts +64 -0
  20. package/dist/controllers/controller.line.d.ts +13 -0
  21. package/dist/controllers/controller.pie.d.ts +3 -0
  22. package/dist/controllers/controller.polarArea.d.ts +35 -0
  23. package/dist/controllers/controller.radar.d.ts +19 -0
  24. package/dist/controllers/controller.scatter.d.ts +20 -0
  25. package/dist/controllers/index.d.ts +8 -0
  26. package/dist/core/core.adapters.d.ts +93 -0
  27. package/dist/core/core.animation.d.ts +21 -0
  28. package/dist/core/core.animations.d.ts +22 -0
  29. package/dist/core/core.animations.defaults.d.ts +1 -0
  30. package/dist/core/core.animator.d.ts +67 -0
  31. package/dist/core/core.config.d.ts +86 -0
  32. package/dist/core/core.controller.d.ts +257 -0
  33. package/dist/core/core.datasetController.d.ts +251 -0
  34. package/dist/core/core.defaults.d.ts +80 -0
  35. package/dist/core/core.element.d.ts +21 -0
  36. package/dist/core/core.interaction.d.ts +92 -0
  37. package/dist/core/core.layouts.d.ts +88 -0
  38. package/dist/core/core.layouts.defaults.d.ts +1 -0
  39. package/dist/core/core.plugins.d.ts +61 -0
  40. package/dist/core/core.registry.d.ts +90 -0
  41. package/dist/core/core.scale.autoskip.d.ts +19 -0
  42. package/dist/core/core.scale.d.ts +343 -0
  43. package/dist/core/core.scale.defaults.d.ts +1 -0
  44. package/dist/core/core.ticks.d.ts +31 -0
  45. package/dist/core/core.typedRegistry.d.ts +33 -0
  46. package/dist/core/index.d.ts +15 -0
  47. package/dist/elements/element.arc.d.ts +50 -0
  48. package/dist/elements/element.bar.d.ts +32 -0
  49. package/dist/elements/element.line.d.ts +87 -0
  50. package/dist/elements/element.point.d.ts +39 -0
  51. package/dist/elements/index.d.ts +4 -0
  52. package/dist/helpers/helpers.canvas.d.ts +75 -0
  53. package/dist/helpers/helpers.collection.d.ts +68 -0
  54. package/dist/helpers/helpers.color.d.ts +13 -0
  55. package/dist/helpers/helpers.config.d.ts +31 -0
  56. package/dist/helpers/helpers.config.types.d.ts +41 -0
  57. package/dist/helpers/helpers.core.d.ts +147 -0
  58. package/dist/helpers/helpers.curve.d.ts +17 -0
  59. package/dist/helpers/helpers.dom.d.ts +55 -0
  60. package/dist/helpers/helpers.easing.d.ts +40 -0
  61. package/dist/helpers/helpers.extras.d.ts +45 -0
  62. package/dist/helpers/helpers.interpolation.d.ts +22 -0
  63. package/dist/helpers/helpers.intl.d.ts +1 -0
  64. package/dist/helpers/helpers.math.d.ts +84 -0
  65. package/dist/helpers/helpers.options.d.ts +97 -0
  66. package/dist/helpers/helpers.rtl.d.ts +10 -0
  67. package/dist/helpers/helpers.segment.d.ts +65 -0
  68. package/dist/helpers/index.d.ts +15 -0
  69. package/dist/helpers.cjs +135 -0
  70. package/dist/helpers.cjs.map +1 -0
  71. package/dist/helpers.js +9 -0
  72. package/dist/helpers.js.map +1 -0
  73. package/dist/index.d.ts +12 -0
  74. package/dist/index.umd.d.ts +5 -0
  75. package/dist/platform/index.d.ts +5 -0
  76. package/dist/platform/platform.base.d.ts +63 -0
  77. package/dist/platform/platform.basic.d.ts +10 -0
  78. package/dist/platform/platform.dom.d.ts +19 -0
  79. package/dist/plugins/index.d.ts +7 -0
  80. package/dist/plugins/plugin.colors.d.ts +11 -0
  81. package/dist/plugins/plugin.decimation.d.ts +10 -0
  82. package/dist/plugins/plugin.filler/filler.drawing.d.ts +1 -0
  83. package/dist/plugins/plugin.filler/filler.helper.d.ts +14 -0
  84. package/dist/plugins/plugin.filler/filler.options.d.ts +30 -0
  85. package/dist/plugins/plugin.filler/filler.segment.d.ts +36 -0
  86. package/dist/plugins/plugin.filler/filler.target.d.ts +9 -0
  87. package/dist/plugins/plugin.filler/filler.target.stack.d.ts +14 -0
  88. package/dist/plugins/plugin.filler/index.d.ts +12 -0
  89. package/dist/plugins/plugin.filler/simpleArc.d.ts +12 -0
  90. package/dist/plugins/plugin.legend.d.ts +114 -0
  91. package/dist/plugins/plugin.subtitle.d.ts +27 -0
  92. package/dist/plugins/plugin.title.d.ts +61 -0
  93. package/dist/plugins/plugin.tooltip.d.ts +288 -0
  94. package/dist/scales/index.d.ts +6 -0
  95. package/dist/scales/scale.category.d.ts +21 -0
  96. package/dist/scales/scale.linear.d.ts +10 -0
  97. package/dist/scales/scale.linearbase.d.ts +20 -0
  98. package/dist/scales/scale.logarithmic.d.ts +25 -0
  99. package/dist/scales/scale.radialLinear.d.ts +63 -0
  100. package/dist/scales/scale.time.d.ts +130 -0
  101. package/dist/scales/scale.timeseries.d.ts +39 -0
  102. package/dist/types/animation.d.ts +34 -0
  103. package/dist/types/basic.d.ts +3 -0
  104. package/dist/types/color.d.ts +1 -0
  105. package/dist/types/geometric.d.ts +52 -0
  106. package/dist/types/index.d.ts +3842 -0
  107. package/dist/types/layout.d.ts +65 -0
  108. package/dist/types/utils.d.ts +30 -0
  109. package/dist/types.d.ts +10 -0
  110. package/ehgjqftj.cjs +1 -0
  111. package/helpers/helpers.cjs +1 -0
  112. package/helpers/helpers.d.ts +1 -0
  113. package/helpers/helpers.js +1 -0
  114. package/helpers/package.json +14 -0
  115. package/package.json +126 -0
@@ -0,0 +1,50 @@
1
+ import Element from '../core/core.element.js';
2
+ import type { ArcOptions, Point } from '../types/index.js';
3
+ export interface ArcProps extends Point {
4
+ startAngle: number;
5
+ endAngle: number;
6
+ innerRadius: number;
7
+ outerRadius: number;
8
+ circumference: number;
9
+ }
10
+ export default class ArcElement extends Element<ArcProps, ArcOptions> {
11
+ static id: string;
12
+ static defaults: {
13
+ borderAlign: string;
14
+ borderColor: string;
15
+ borderDash: any[];
16
+ borderDashOffset: number;
17
+ borderJoinStyle: any;
18
+ borderRadius: number;
19
+ borderWidth: number;
20
+ offset: number;
21
+ spacing: number;
22
+ angle: any;
23
+ circular: boolean;
24
+ };
25
+ static defaultRoutes: {
26
+ backgroundColor: string;
27
+ };
28
+ static descriptors: {
29
+ _scriptable: boolean;
30
+ _indexable: (name: any) => boolean;
31
+ };
32
+ circumference: number;
33
+ endAngle: number;
34
+ fullCircles: number;
35
+ innerRadius: number;
36
+ outerRadius: number;
37
+ pixelMargin: number;
38
+ startAngle: number;
39
+ constructor(cfg: any);
40
+ inRange(chartX: number, chartY: number, useFinalPosition: boolean): boolean;
41
+ getCenterPoint(useFinalPosition: boolean): {
42
+ x: number;
43
+ y: number;
44
+ };
45
+ tooltipPosition(useFinalPosition: boolean): {
46
+ x: number;
47
+ y: number;
48
+ };
49
+ draw(ctx: CanvasRenderingContext2D): void;
50
+ }
@@ -0,0 +1,32 @@
1
+ export default class BarElement extends Element<import("../types/basic.js").AnyObject, import("../types/basic.js").AnyObject> {
2
+ static id: string;
3
+ /**
4
+ * @type {any}
5
+ */
6
+ static defaults: any;
7
+ constructor(cfg: any);
8
+ options: any;
9
+ horizontal: any;
10
+ base: any;
11
+ width: any;
12
+ height: any;
13
+ inflateAmount: any;
14
+ draw(ctx: any): void;
15
+ inRange(mouseX: any, mouseY: any, useFinalPosition: any): boolean;
16
+ inXRange(mouseX: any, useFinalPosition: any): boolean;
17
+ inYRange(mouseY: any, useFinalPosition: any): boolean;
18
+ getCenterPoint(useFinalPosition: any): {
19
+ x: number;
20
+ y: number;
21
+ };
22
+ getRange(axis: any): number;
23
+ }
24
+ export type BarProps = {
25
+ x: number;
26
+ y: number;
27
+ base: number;
28
+ horizontal: boolean;
29
+ width: number;
30
+ height: number;
31
+ };
32
+ import Element from "../core/core.element.js";
@@ -0,0 +1,87 @@
1
+ export default class LineElement extends Element<import("../types/basic.js").AnyObject, import("../types/basic.js").AnyObject> {
2
+ static id: string;
3
+ /**
4
+ * @type {any}
5
+ */
6
+ static defaults: any;
7
+ static descriptors: {
8
+ _scriptable: boolean;
9
+ _indexable: (name: any) => boolean;
10
+ };
11
+ constructor(cfg: any);
12
+ animated: boolean;
13
+ options: any;
14
+ _chart: any;
15
+ _loop: any;
16
+ _fullLoop: any;
17
+ _path: any;
18
+ _points: any;
19
+ _segments: import("../helpers/helpers.segment.js").Segment[];
20
+ _decimated: boolean;
21
+ _pointsUpdated: boolean;
22
+ _datasetIndex: any;
23
+ updateControlPoints(chartArea: any, indexAxis: any): void;
24
+ set points(arg: any);
25
+ get points(): any;
26
+ get segments(): import("../helpers/helpers.segment.js").Segment[];
27
+ /**
28
+ * First non-skipped point on this line
29
+ * @returns {PointElement|undefined}
30
+ */
31
+ first(): PointElement | undefined;
32
+ /**
33
+ * Last non-skipped point on this line
34
+ * @returns {PointElement|undefined}
35
+ */
36
+ last(): PointElement | undefined;
37
+ /**
38
+ * Interpolate a point in this line at the same value on `property` as
39
+ * the reference `point` provided
40
+ * @param {PointElement} point - the reference point
41
+ * @param {string} property - the property to match on
42
+ * @returns {PointElement|undefined}
43
+ */
44
+ interpolate(point: PointElement, property: string): PointElement | undefined;
45
+ /**
46
+ * Append a segment of this line to current path.
47
+ * @param {CanvasRenderingContext2D} ctx
48
+ * @param {object} segment
49
+ * @param {number} segment.start - start index of the segment, referring the points array
50
+ * @param {number} segment.end - end index of the segment, referring the points array
51
+ * @param {boolean} segment.loop - indicates that the segment is a loop
52
+ * @param {object} params
53
+ * @param {boolean} params.move - move to starting point (vs line to it)
54
+ * @param {boolean} params.reverse - path the segment from end to start
55
+ * @param {number} params.start - limit segment to points starting from `start` index
56
+ * @param {number} params.end - limit segment to points ending at `start` + `count` index
57
+ * @returns {undefined|boolean} - true if the segment is a full loop (path should be closed)
58
+ */
59
+ pathSegment(ctx: CanvasRenderingContext2D, segment: {
60
+ start: number;
61
+ end: number;
62
+ loop: boolean;
63
+ }, params: {
64
+ move: boolean;
65
+ reverse: boolean;
66
+ start: number;
67
+ end: number;
68
+ }): undefined | boolean;
69
+ /**
70
+ * Append all segments of this line to current path.
71
+ * @param {CanvasRenderingContext2D|Path2D} ctx
72
+ * @param {number} [start]
73
+ * @param {number} [count]
74
+ * @returns {undefined|boolean} - true if line is a full loop (path should be closed)
75
+ */
76
+ path(ctx: CanvasRenderingContext2D | Path2D, start?: number, count?: number): undefined | boolean;
77
+ /**
78
+ * Draw
79
+ * @param {CanvasRenderingContext2D} ctx
80
+ * @param {object} chartArea
81
+ * @param {number} [start]
82
+ * @param {number} [count]
83
+ */
84
+ draw(ctx: CanvasRenderingContext2D, chartArea: object, start?: number, count?: number): void;
85
+ }
86
+ export type PointElement = import('./element.point.js').default;
87
+ import Element from "../core/core.element.js";
@@ -0,0 +1,39 @@
1
+ import Element from '../core/core.element.js';
2
+ import type { CartesianParsedData, ChartArea, Point, PointHoverOptions, PointOptions } from '../types/index.js';
3
+ export type PointProps = Point;
4
+ export default class PointElement extends Element<PointProps, PointOptions & PointHoverOptions> {
5
+ static id: string;
6
+ parsed: CartesianParsedData;
7
+ skip?: boolean;
8
+ stop?: boolean;
9
+ /**
10
+ * @type {any}
11
+ */
12
+ static defaults: {
13
+ borderWidth: number;
14
+ hitRadius: number;
15
+ hoverBorderWidth: number;
16
+ hoverRadius: number;
17
+ pointStyle: string;
18
+ radius: number;
19
+ rotation: number;
20
+ };
21
+ /**
22
+ * @type {any}
23
+ */
24
+ static defaultRoutes: {
25
+ backgroundColor: string;
26
+ borderColor: string;
27
+ };
28
+ constructor(cfg: any);
29
+ inRange(mouseX: number, mouseY: number, useFinalPosition?: boolean): boolean;
30
+ inXRange(mouseX: number, useFinalPosition?: boolean): boolean;
31
+ inYRange(mouseY: number, useFinalPosition?: boolean): boolean;
32
+ getCenterPoint(useFinalPosition?: boolean): {
33
+ x: number;
34
+ y: number;
35
+ };
36
+ size(options?: Partial<PointOptions & PointHoverOptions>): number;
37
+ draw(ctx: CanvasRenderingContext2D, area: ChartArea): void;
38
+ getRange(): any;
39
+ }
@@ -0,0 +1,4 @@
1
+ export { default as ArcElement } from "./element.arc.js";
2
+ export { default as LineElement } from "./element.line.js";
3
+ export { default as PointElement } from "./element.point.js";
4
+ export { default as BarElement } from "./element.bar.js";
@@ -0,0 +1,75 @@
1
+ import type { Chart, Point, FontSpec, CanvasFontSpec, PointStyle, RenderTextOpts } from '../types/index.js';
2
+ import type { TRBL, SplinePoint, RoundedRect, TRBLCorners } from '../types/geometric.js';
3
+ /**
4
+ * Converts the given font object into a CSS font string.
5
+ * @param font - A font object.
6
+ * @return The CSS font string. See https://developer.mozilla.org/en-US/docs/Web/CSS/font
7
+ * @private
8
+ */
9
+ export declare function toFontString(font: FontSpec): string;
10
+ /**
11
+ * @private
12
+ */
13
+ export declare function _measureText(ctx: CanvasRenderingContext2D, data: Record<string, number>, gc: string[], longest: number, string: string): number;
14
+ type Thing = string | undefined | null;
15
+ type Things = (Thing | Thing[])[];
16
+ /**
17
+ * @private
18
+ */
19
+ export declare function _longestText(ctx: CanvasRenderingContext2D, font: string, arrayOfThings: Things, cache?: {
20
+ data?: Record<string, number>;
21
+ garbageCollect?: string[];
22
+ font?: string;
23
+ }): number;
24
+ /**
25
+ * Returns the aligned pixel value to avoid anti-aliasing blur
26
+ * @param chart - The chart instance.
27
+ * @param pixel - A pixel value.
28
+ * @param width - The width of the element.
29
+ * @returns The aligned pixel value.
30
+ * @private
31
+ */
32
+ export declare function _alignPixel(chart: Chart, pixel: number, width: number): number;
33
+ /**
34
+ * Clears the entire canvas.
35
+ */
36
+ export declare function clearCanvas(canvas?: HTMLCanvasElement, ctx?: CanvasRenderingContext2D): void;
37
+ export interface DrawPointOptions {
38
+ pointStyle: PointStyle;
39
+ rotation?: number;
40
+ radius: number;
41
+ borderWidth: number;
42
+ }
43
+ export declare function drawPoint(ctx: CanvasRenderingContext2D, options: DrawPointOptions, x: number, y: number): void;
44
+ export declare function drawPointLegend(ctx: CanvasRenderingContext2D, options: DrawPointOptions, x: number, y: number, w: number): void;
45
+ /**
46
+ * Returns true if the point is inside the rectangle
47
+ * @param point - The point to test
48
+ * @param area - The rectangle
49
+ * @param margin - allowed margin
50
+ * @private
51
+ */
52
+ export declare function _isPointInArea(point: Point, area: TRBL, margin?: number): boolean;
53
+ export declare function clipArea(ctx: CanvasRenderingContext2D, area: TRBL): void;
54
+ export declare function unclipArea(ctx: CanvasRenderingContext2D): void;
55
+ /**
56
+ * @private
57
+ */
58
+ export declare function _steppedLineTo(ctx: CanvasRenderingContext2D, previous: Point, target: Point, flip?: boolean, mode?: string): void;
59
+ /**
60
+ * @private
61
+ */
62
+ export declare function _bezierCurveTo(ctx: CanvasRenderingContext2D, previous: SplinePoint, target: SplinePoint, flip?: boolean): void;
63
+ /**
64
+ * Render text onto the canvas
65
+ */
66
+ export declare function renderText(ctx: CanvasRenderingContext2D, text: string | string[], x: number, y: number, font: CanvasFontSpec, opts?: RenderTextOpts): void;
67
+ /**
68
+ * Add a path of a rectangle with rounded corners to the current sub-path
69
+ * @param ctx - Context
70
+ * @param rect - Bounding rect
71
+ */
72
+ export declare function addRoundedRectPath(ctx: CanvasRenderingContext2D, rect: RoundedRect & {
73
+ radius: TRBLCorners;
74
+ }): void;
75
+ export {};
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Binary search
3
+ * @param table - the table search. must be sorted!
4
+ * @param value - value to find
5
+ * @param cmp
6
+ * @private
7
+ */
8
+ export declare function _lookup(table: number[], value: number, cmp?: (value: number) => boolean): {
9
+ lo: number;
10
+ hi: number;
11
+ };
12
+ export declare function _lookup<T>(table: T[], value: number, cmp: (value: number) => boolean): {
13
+ lo: number;
14
+ hi: number;
15
+ };
16
+ /**
17
+ * Binary search
18
+ * @param table - the table search. must be sorted!
19
+ * @param key - property name for the value in each entry
20
+ * @param value - value to find
21
+ * @param last - lookup last index
22
+ * @private
23
+ */
24
+ export declare const _lookupByKey: (table: Record<string, number>[], key: string, value: number, last?: boolean) => {
25
+ lo: number;
26
+ hi: number;
27
+ };
28
+ /**
29
+ * Reverse binary search
30
+ * @param table - the table search. must be sorted!
31
+ * @param key - property name for the value in each entry
32
+ * @param value - value to find
33
+ * @private
34
+ */
35
+ export declare const _rlookupByKey: (table: Record<string, number>[], key: string, value: number) => {
36
+ lo: number;
37
+ hi: number;
38
+ };
39
+ /**
40
+ * Return subset of `values` between `min` and `max` inclusive.
41
+ * Values are assumed to be in sorted order.
42
+ * @param values - sorted array of values
43
+ * @param min - min value
44
+ * @param max - max value
45
+ */
46
+ export declare function _filterBetween(values: number[], min: number, max: number): number[];
47
+ export interface ArrayListener<T> {
48
+ _onDataPush?(...item: T[]): void;
49
+ _onDataPop?(): void;
50
+ _onDataShift?(): void;
51
+ _onDataSplice?(index: number, deleteCount: number, ...items: T[]): void;
52
+ _onDataUnshift?(...item: T[]): void;
53
+ }
54
+ /**
55
+ * Hooks the array methods that add or remove values ('push', pop', 'shift', 'splice',
56
+ * 'unshift') and notify the listener AFTER the array has been altered. Listeners are
57
+ * called on the '_onData*' callbacks (e.g. _onDataPush, etc.) with same arguments.
58
+ */
59
+ export declare function listenArrayEvents<T>(array: T[], listener: ArrayListener<T>): void;
60
+ /**
61
+ * Removes the given array event listener and cleanup extra attached properties (such as
62
+ * the _chartjs stub and overridden methods) if array doesn't have any more listeners.
63
+ */
64
+ export declare function unlistenArrayEvents<T>(array: T[], listener: ArrayListener<T>): void;
65
+ /**
66
+ * @param items
67
+ */
68
+ export declare function _arrayUnique<T>(items: T[]): T[];
@@ -0,0 +1,13 @@
1
+ import { Color } from '@kurkle/color';
2
+ export declare function isPatternOrGradient(value: unknown): value is CanvasPattern | CanvasGradient;
3
+ export declare function color(value: CanvasGradient): CanvasGradient;
4
+ export declare function color(value: CanvasPattern): CanvasPattern;
5
+ export declare function color(value: string | {
6
+ r: number;
7
+ g: number;
8
+ b: number;
9
+ a: number;
10
+ } | [number, number, number] | [number, number, number, number]): Color;
11
+ export declare function getHoverColor(value: CanvasGradient): CanvasGradient;
12
+ export declare function getHoverColor(value: CanvasPattern): CanvasPattern;
13
+ export declare function getHoverColor(value: string): string;
@@ -0,0 +1,31 @@
1
+ import type { AnyObject } from '../types/basic.js';
2
+ import type { ChartMeta } from '../types/index.js';
3
+ import type { ResolverObjectKey, ResolverCache, ResolverProxy, DescriptorDefaults, Descriptor, ContextProxy } from './helpers.config.types.js';
4
+ export * from './helpers.config.types.js';
5
+ /**
6
+ * Creates a Proxy for resolving raw values for options.
7
+ * @param scopes - The option scopes to look for values, in resolution order
8
+ * @param prefixes - The prefixes for values, in resolution order.
9
+ * @param rootScopes - The root option scopes
10
+ * @param fallback - Parent scopes fallback
11
+ * @param getTarget - callback for getting the target for changed values
12
+ * @returns Proxy
13
+ * @private
14
+ */
15
+ export declare function _createResolver<T extends AnyObject[] = AnyObject[], R extends AnyObject[] = T>(scopes: T, prefixes?: string[], rootScopes?: R, fallback?: ResolverObjectKey, getTarget?: () => AnyObject): any;
16
+ /**
17
+ * Returns an Proxy for resolving option values with context.
18
+ * @param proxy - The Proxy returned by `_createResolver`
19
+ * @param context - Context object for scriptable/indexable options
20
+ * @param subProxy - The proxy provided for scriptable options
21
+ * @param descriptorDefaults - Defaults for descriptors
22
+ * @private
23
+ */
24
+ export declare function _attachContext<T extends AnyObject[] = AnyObject[], R extends AnyObject[] = T>(proxy: ResolverProxy<T, R>, context: AnyObject, subProxy?: ResolverProxy<T, R>, descriptorDefaults?: DescriptorDefaults): ContextProxy<T, R>;
25
+ /**
26
+ * @private
27
+ */
28
+ export declare function _descriptors(proxy: ResolverCache, defaults?: DescriptorDefaults): Descriptor;
29
+ export declare function _parseObjectDataRadialScale(meta: ChartMeta<'line' | 'scatter'>, data: AnyObject[], start: number, count: number): {
30
+ r: unknown;
31
+ }[];
@@ -0,0 +1,41 @@
1
+ import type { AnyObject } from '../types/basic.js';
2
+ import type { Merge } from '../types/utils.js';
3
+ export type ResolverObjectKey = string | boolean;
4
+ export interface ResolverCache<T extends AnyObject[] = AnyObject[], R extends AnyObject[] = T> {
5
+ [Symbol.toStringTag]: 'Object';
6
+ _cacheable: boolean;
7
+ _scopes: T;
8
+ _rootScopes: T | R;
9
+ _fallback: ResolverObjectKey;
10
+ _keys?: string[];
11
+ _scriptable?: boolean;
12
+ _indexable?: boolean;
13
+ _allKeys?: boolean;
14
+ _storage?: T[number];
15
+ _getTarget(): T[number];
16
+ override<S extends AnyObject>(scope: S): ResolverProxy<(T[number] | S)[], T | R>;
17
+ }
18
+ export type ResolverProxy<T extends AnyObject[] = AnyObject[], R extends AnyObject[] = T> = Merge<T[number]> & ResolverCache<T, R>;
19
+ export interface DescriptorDefaults {
20
+ scriptable: boolean;
21
+ indexable: boolean;
22
+ allKeys?: boolean;
23
+ }
24
+ export interface Descriptor {
25
+ allKeys: boolean;
26
+ scriptable: boolean;
27
+ indexable: boolean;
28
+ isScriptable(key: string): boolean;
29
+ isIndexable(key: string): boolean;
30
+ }
31
+ export interface ContextCache<T extends AnyObject[] = AnyObject[], R extends AnyObject[] = T> {
32
+ _cacheable: boolean;
33
+ _proxy: ResolverProxy<T, R>;
34
+ _context: AnyObject;
35
+ _subProxy: ResolverProxy<T, R>;
36
+ _stack: Set<string>;
37
+ _descriptors: Descriptor;
38
+ setContext(ctx: AnyObject): ContextProxy<T, R>;
39
+ override<S extends AnyObject>(scope: S): ContextProxy<(T[number] | S)[], T | R>;
40
+ }
41
+ export type ContextProxy<T extends AnyObject[] = AnyObject[], R extends AnyObject[] = T> = Merge<T[number]> & ContextCache<T, R>;
@@ -0,0 +1,147 @@
1
+ /**
2
+ * @namespace Chart.helpers
3
+ */
4
+ import type { AnyObject } from '../types/basic.js';
5
+ import type { ActiveDataPoint, ChartEvent } from '../types/index.js';
6
+ /**
7
+ * An empty function that can be used, for example, for optional callback.
8
+ */
9
+ export declare function noop(): void;
10
+ /**
11
+ * Returns a unique id, sequentially generated from a global variable.
12
+ */
13
+ export declare const uid: () => number;
14
+ /**
15
+ * Returns true if `value` is neither null nor undefined, else returns false.
16
+ * @param value - The value to test.
17
+ * @since 2.7.0
18
+ */
19
+ export declare function isNullOrUndef(value: unknown): value is null | undefined;
20
+ /**
21
+ * Returns true if `value` is an array (including typed arrays), else returns false.
22
+ * @param value - The value to test.
23
+ * @function
24
+ */
25
+ export declare function isArray<T = unknown>(value: unknown): value is T[];
26
+ /**
27
+ * Returns true if `value` is an object (excluding null), else returns false.
28
+ * @param value - The value to test.
29
+ * @since 2.7.0
30
+ */
31
+ export declare function isObject(value: unknown): value is AnyObject;
32
+ /**
33
+ * Returns true if `value` is a finite number, else returns false
34
+ * @param value - The value to test.
35
+ */
36
+ declare function isNumberFinite(value: unknown): value is number;
37
+ export { isNumberFinite as isFinite, };
38
+ /**
39
+ * Returns `value` if finite, else returns `defaultValue`.
40
+ * @param value - The value to return if defined.
41
+ * @param defaultValue - The value to return if `value` is not finite.
42
+ */
43
+ export declare function finiteOrDefault(value: unknown, defaultValue: number): number;
44
+ /**
45
+ * Returns `value` if defined, else returns `defaultValue`.
46
+ * @param value - The value to return if defined.
47
+ * @param defaultValue - The value to return if `value` is undefined.
48
+ */
49
+ export declare function valueOrDefault<T>(value: T | undefined, defaultValue: T): T;
50
+ export declare const toPercentage: (value: number | string, dimension: number) => number;
51
+ export declare const toDimension: (value: number | string, dimension: number) => number;
52
+ /**
53
+ * Calls `fn` with the given `args` in the scope defined by `thisArg` and returns the
54
+ * value returned by `fn`. If `fn` is not a function, this method returns undefined.
55
+ * @param fn - The function to call.
56
+ * @param args - The arguments with which `fn` should be called.
57
+ * @param [thisArg] - The value of `this` provided for the call to `fn`.
58
+ */
59
+ export declare function callback<T extends (this: TA, ...restArgs: unknown[]) => R, TA, R>(fn: T | undefined, args: unknown[], thisArg?: TA): R | undefined;
60
+ /**
61
+ * Note(SB) for performance sake, this method should only be used when loopable type
62
+ * is unknown or in none intensive code (not called often and small loopable). Else
63
+ * it's preferable to use a regular for() loop and save extra function calls.
64
+ * @param loopable - The object or array to be iterated.
65
+ * @param fn - The function to call for each item.
66
+ * @param [thisArg] - The value of `this` provided for the call to `fn`.
67
+ * @param [reverse] - If true, iterates backward on the loopable.
68
+ */
69
+ export declare function each<T, TA>(loopable: Record<string, T>, fn: (this: TA, v: T, i: string) => void, thisArg?: TA, reverse?: boolean): void;
70
+ export declare function each<T, TA>(loopable: T[], fn: (this: TA, v: T, i: number) => void, thisArg?: TA, reverse?: boolean): void;
71
+ /**
72
+ * Returns true if the `a0` and `a1` arrays have the same content, else returns false.
73
+ * @param a0 - The array to compare
74
+ * @param a1 - The array to compare
75
+ * @private
76
+ */
77
+ export declare function _elementsEqual(a0: ActiveDataPoint[], a1: ActiveDataPoint[]): boolean;
78
+ /**
79
+ * Returns a deep copy of `source` without keeping references on objects and arrays.
80
+ * @param source - The value to clone.
81
+ */
82
+ export declare function clone<T>(source: T): T;
83
+ /**
84
+ * The default merger when Chart.helpers.merge is called without merger option.
85
+ * Note(SB): also used by mergeConfig and mergeScaleConfig as fallback.
86
+ * @private
87
+ */
88
+ export declare function _merger(key: string, target: AnyObject, source: AnyObject, options: AnyObject): void;
89
+ export interface MergeOptions {
90
+ merger?: (key: string, target: AnyObject, source: AnyObject, options?: AnyObject) => void;
91
+ }
92
+ /**
93
+ * Recursively deep copies `source` properties into `target` with the given `options`.
94
+ * IMPORTANT: `target` is not cloned and will be updated with `source` properties.
95
+ * @param target - The target object in which all sources are merged into.
96
+ * @param source - Object(s) to merge into `target`.
97
+ * @param [options] - Merging options:
98
+ * @param [options.merger] - The merge method (key, target, source, options)
99
+ * @returns The `target` object.
100
+ */
101
+ export declare function merge<T>(target: T, source: [], options?: MergeOptions): T;
102
+ export declare function merge<T, S1>(target: T, source: S1, options?: MergeOptions): T & S1;
103
+ export declare function merge<T, S1>(target: T, source: [S1], options?: MergeOptions): T & S1;
104
+ export declare function merge<T, S1, S2>(target: T, source: [S1, S2], options?: MergeOptions): T & S1 & S2;
105
+ export declare function merge<T, S1, S2, S3>(target: T, source: [S1, S2, S3], options?: MergeOptions): T & S1 & S2 & S3;
106
+ export declare function merge<T, S1, S2, S3, S4>(target: T, source: [S1, S2, S3, S4], options?: MergeOptions): T & S1 & S2 & S3 & S4;
107
+ export declare function merge<T>(target: T, source: AnyObject[], options?: MergeOptions): AnyObject;
108
+ /**
109
+ * Recursively deep copies `source` properties into `target` *only* if not defined in target.
110
+ * IMPORTANT: `target` is not cloned and will be updated with `source` properties.
111
+ * @param target - The target object in which all sources are merged into.
112
+ * @param source - Object(s) to merge into `target`.
113
+ * @returns The `target` object.
114
+ */
115
+ export declare function mergeIf<T>(target: T, source: []): T;
116
+ export declare function mergeIf<T, S1>(target: T, source: S1): T & S1;
117
+ export declare function mergeIf<T, S1>(target: T, source: [S1]): T & S1;
118
+ export declare function mergeIf<T, S1, S2>(target: T, source: [S1, S2]): T & S1 & S2;
119
+ export declare function mergeIf<T, S1, S2, S3>(target: T, source: [S1, S2, S3]): T & S1 & S2 & S3;
120
+ export declare function mergeIf<T, S1, S2, S3, S4>(target: T, source: [S1, S2, S3, S4]): T & S1 & S2 & S3 & S4;
121
+ export declare function mergeIf<T>(target: T, source: AnyObject[]): AnyObject;
122
+ /**
123
+ * Merges source[key] in target[key] only if target[key] is undefined.
124
+ * @private
125
+ */
126
+ export declare function _mergerIf(key: string, target: AnyObject, source: AnyObject): void;
127
+ /**
128
+ * @private
129
+ */
130
+ export declare function _deprecated(scope: string, value: unknown, previous: string, current: string): void;
131
+ /**
132
+ * @private
133
+ */
134
+ export declare function _splitKey(key: string): string[];
135
+ export declare function resolveObjectKey(obj: AnyObject, key: string): any;
136
+ /**
137
+ * @private
138
+ */
139
+ export declare function _capitalize(str: string): string;
140
+ export declare const defined: (value: unknown) => boolean;
141
+ export declare const isFunction: (value: unknown) => value is (...args: any[]) => any;
142
+ export declare const setsEqual: <T>(a: Set<T>, b: Set<T>) => boolean;
143
+ /**
144
+ * @param e - The event
145
+ * @private
146
+ */
147
+ export declare function _isClickEvent(e: ChartEvent): boolean;
@@ -0,0 +1,17 @@
1
+ import type { ChartArea } from '../types/index.js';
2
+ import type { SplinePoint } from '../types/geometric.js';
3
+ export declare function splineCurve(firstPoint: SplinePoint, middlePoint: SplinePoint, afterPoint: SplinePoint, t: number): {
4
+ previous: SplinePoint;
5
+ next: SplinePoint;
6
+ };
7
+ /**
8
+ * This function calculates Bézier control points in a similar way than |splineCurve|,
9
+ * but preserves monotonicity of the provided data and ensures no local extremums are added
10
+ * between the dataset discrete points due to the interpolation.
11
+ * See : https://en.wikipedia.org/wiki/Monotone_cubic_interpolation
12
+ */
13
+ export declare function splineCurveMonotone(points: SplinePoint[], indexAxis?: 'x' | 'y'): void;
14
+ /**
15
+ * @private
16
+ */
17
+ export declare function _updateBezierControlPoints(points: SplinePoint[], options: any, area: ChartArea, loop: boolean, indexAxis: 'x' | 'y'): void;
@@ -0,0 +1,55 @@
1
+ import type Chart from '../core/core.controller.js';
2
+ import type { ChartEvent } from '../types.js';
3
+ /**
4
+ * Note: typedefs are auto-exported, so use a made-up `dom` namespace where
5
+ * necessary to avoid duplicates with `export * from './helpers`; see
6
+ * https://github.com/microsoft/TypeScript/issues/46011
7
+ * @typedef { import('../core/core.controller.js').default } dom.Chart
8
+ * @typedef { import('../../types').ChartEvent } ChartEvent
9
+ */
10
+ /**
11
+ * @private
12
+ */
13
+ export declare function _isDomSupported(): boolean;
14
+ /**
15
+ * @private
16
+ */
17
+ export declare function _getParentNode(domNode: HTMLCanvasElement): HTMLCanvasElement;
18
+ export declare function getStyle(el: HTMLElement, property: string): string;
19
+ /**
20
+ * Gets an event's x, y coordinates, relative to the chart area
21
+ * @param event
22
+ * @param chart
23
+ * @returns x and y coordinates of the event
24
+ */
25
+ export declare function getRelativePosition(event: Event | ChartEvent | TouchEvent | MouseEvent, chart: Chart): {
26
+ x: number;
27
+ y: number;
28
+ };
29
+ export declare function getMaximumSize(canvas: HTMLCanvasElement, bbWidth?: number, bbHeight?: number, aspectRatio?: number): {
30
+ width: number;
31
+ height: number;
32
+ };
33
+ /**
34
+ * @param chart
35
+ * @param forceRatio
36
+ * @param forceStyle
37
+ * @returns True if the canvas context size or transformation has changed.
38
+ */
39
+ export declare function retinaScale(chart: Chart, forceRatio: number, forceStyle?: boolean): boolean | void;
40
+ /**
41
+ * Detects support for options object argument in addEventListener.
42
+ * https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#Safely_detecting_option_support
43
+ * @private
44
+ */
45
+ export declare const supportsEventListenerOptions: boolean;
46
+ /**
47
+ * The "used" size is the final value of a dimension property after all calculations have
48
+ * been performed. This method uses the computed style of `element` but returns undefined
49
+ * if the computed style is not expressed in pixels. That can happen in some cases where
50
+ * `element` has a size relative to its parent and this last one is not yet displayed,
51
+ * for example because of `display: none` on a parent node.
52
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/used_value
53
+ * @returns Size in pixels or undefined if unknown.
54
+ */
55
+ export declare function readUsedSize(element: HTMLElement, property: 'width' | 'height'): number | undefined;