Add chartjs

This commit is contained in:
2024-03-03 01:01:07 +01:00
parent 481492868b
commit b4794ca42f
114 changed files with 37057 additions and 0 deletions

93
chartjs/dist/core/core.adapters.d.ts vendored Normal file
View File

@ -0,0 +1,93 @@
/**
* @namespace Chart._adapters
* @since 2.8.0
* @private
*/
import type { AnyObject } from '../types/basic.js';
import type { ChartOptions } from '../types/index.js';
export type TimeUnit = 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year';
export interface DateAdapter<T extends AnyObject = AnyObject> {
readonly options: T;
/**
* Will called with chart options after adapter creation.
*/
init(this: DateAdapter<T>, chartOptions: ChartOptions): void;
/**
* Returns a map of time formats for the supported formatting units defined
* in Unit as well as 'datetime' representing a detailed date/time string.
*/
formats(this: DateAdapter<T>): Record<string, string>;
/**
* Parses the given `value` and return the associated timestamp.
* @param value - the value to parse (usually comes from the data)
* @param [format] - the expected data format
*/
parse(this: DateAdapter<T>, value: unknown, format?: TimeUnit): number | null;
/**
* Returns the formatted date in the specified `format` for a given `timestamp`.
* @param timestamp - the timestamp to format
* @param format - the date/time token
*/
format(this: DateAdapter<T>, timestamp: number, format: TimeUnit): string;
/**
* Adds the specified `amount` of `unit` to the given `timestamp`.
* @param timestamp - the input timestamp
* @param amount - the amount to add
* @param unit - the unit as string
*/
add(this: DateAdapter<T>, timestamp: number, amount: number, unit: TimeUnit): number;
/**
* Returns the number of `unit` between the given timestamps.
* @param a - the input timestamp (reference)
* @param b - the timestamp to subtract
* @param unit - the unit as string
*/
diff(this: DateAdapter<T>, a: number, b: number, unit: TimeUnit): number;
/**
* Returns start of `unit` for the given `timestamp`.
* @param timestamp - the input timestamp
* @param unit - the unit as string
* @param [weekday] - the ISO day of the week with 1 being Monday
* and 7 being Sunday (only needed if param *unit* is `isoWeek`).
*/
startOf(this: DateAdapter<T>, timestamp: number, unit: TimeUnit | 'isoWeek', weekday?: number): number;
/**
* Returns end of `unit` for the given `timestamp`.
* @param timestamp - the input timestamp
* @param unit - the unit as string
*/
endOf(this: DateAdapter<T>, timestamp: number, unit: TimeUnit | 'isoWeek'): number;
}
/**
* Date adapter (current used by the time scale)
* @namespace Chart._adapters._date
* @memberof Chart._adapters
* @private
*/
declare class DateAdapterBase implements DateAdapter {
/**
* Override default date adapter methods.
* Accepts type parameter to define options type.
* @example
* Chart._adapters._date.override<{myAdapterOption: string}>({
* init() {
* console.log(this.options.myAdapterOption);
* }
* })
*/
static override<T extends AnyObject = AnyObject>(members: Partial<Omit<DateAdapter<T>, 'options'>>): void;
readonly options: AnyObject;
constructor(options: AnyObject);
init(): void;
formats(): Record<string, string>;
parse(): number | null;
format(): string;
add(): number;
diff(): number;
startOf(): number;
endOf(): number;
}
declare const _default: {
_date: typeof DateAdapterBase;
};
export default _default;

21
chartjs/dist/core/core.animation.d.ts vendored Normal file
View File

@ -0,0 +1,21 @@
export default class Animation {
constructor(cfg: any, target: any, prop: any, to: any);
_active: boolean;
_fn: any;
_easing: any;
_start: number;
_duration: number;
_total: number;
_loop: boolean;
_target: any;
_prop: any;
_from: unknown;
_to: any;
_promises: any[];
active(): boolean;
update(cfg: any, to: any, date: any): void;
cancel(): void;
tick(date: any): void;
wait(): Promise<any>;
_notify(resolved: any): void;
}

22
chartjs/dist/core/core.animations.d.ts vendored Normal file
View File

@ -0,0 +1,22 @@
export default class Animations {
constructor(chart: any, config: any);
_chart: any;
_properties: Map<any, any>;
configure(config: any): void;
/**
* Utility to handle animation of `options`.
* @private
*/
private _animateOptions;
/**
* @private
*/
private _createAnimations;
/**
* Update `target` properties to new values, using configured animations
* @param {object} target - object to update
* @param {object} values - new target properties
* @returns {boolean|undefined} - `true` if animations were started
**/
update(target: object, values: object): boolean | undefined;
}

View File

@ -0,0 +1 @@
export function applyAnimationsDefaults(defaults: any): void;

67
chartjs/dist/core/core.animator.d.ts vendored Normal file
View File

@ -0,0 +1,67 @@
/**
* @typedef { import('./core.animation.js').default } Animation
* @typedef { import('./core.controller.js').default } Chart
*/
/**
* Please use the module's default export which provides a singleton instance
* Note: class is export for typedoc
*/
export class Animator {
_request: any;
_charts: Map<any, any>;
_running: boolean;
_lastDate: number;
/**
* @private
*/
private _notify;
/**
* @private
*/
private _refresh;
/**
* @private
*/
private _update;
/**
* @private
*/
private _getAnims;
/**
* @param {Chart} chart
* @param {string} event - event name
* @param {Function} cb - callback
*/
listen(chart: Chart, event: string, cb: Function): void;
/**
* Add animations
* @param {Chart} chart
* @param {Animation[]} items - animations
*/
add(chart: Chart, items: Animation[]): void;
/**
* Counts number of active animations for the chart
* @param {Chart} chart
*/
has(chart: Chart): boolean;
/**
* Start animating (all charts)
* @param {Chart} chart
*/
start(chart: Chart): void;
running(chart: any): boolean;
/**
* Stop all animations for the chart
* @param {Chart} chart
*/
stop(chart: Chart): void;
/**
* Remove chart from Animator
* @param {Chart} chart
*/
remove(chart: Chart): boolean;
}
declare const _default: Animator;
export default _default;
export type Animation = import('./core.animation.js').default;
export type Chart = import('./core.controller.js').default;

86
chartjs/dist/core/core.config.d.ts vendored Normal file
View File

@ -0,0 +1,86 @@
export function getIndexAxis(type: any, options: any): any;
export function determineAxis(id: any, ...scaleOptions: any[]): any;
export default class Config {
constructor(config: any);
_config: any;
_scopeCache: Map<any, any>;
_resolverCache: Map<any, any>;
get platform(): any;
set type(arg: any);
get type(): any;
set data(arg: any);
get data(): any;
set options(arg: any);
get options(): any;
get plugins(): any;
update(): void;
clearCache(): void;
/**
* Returns the option scope keys for resolving dataset options.
* These keys do not include the dataset itself, because it is not under options.
* @param {string} datasetType
* @return {string[][]}
*/
datasetScopeKeys(datasetType: string): string[][];
/**
* Returns the option scope keys for resolving dataset animation options.
* These keys do not include the dataset itself, because it is not under options.
* @param {string} datasetType
* @param {string} transition
* @return {string[][]}
*/
datasetAnimationScopeKeys(datasetType: string, transition: string): string[][];
/**
* Returns the options scope keys for resolving element options that belong
* to an dataset. These keys do not include the dataset itself, because it
* is not under options.
* @param {string} datasetType
* @param {string} elementType
* @return {string[][]}
*/
datasetElementScopeKeys(datasetType: string, elementType: string): string[][];
/**
* Returns the options scope keys for resolving plugin options.
* @param {{id: string, additionalOptionScopes?: string[]}} plugin
* @return {string[][]}
*/
pluginScopeKeys(plugin: {
id: string;
additionalOptionScopes?: string[];
}): string[][];
/**
* @private
*/
private _cachedScopes;
/**
* Resolves the objects from options and defaults for option value resolution.
* @param {object} mainScope - The main scope object for options
* @param {string[][]} keyLists - The arrays of keys in resolution order
* @param {boolean} [resetCache] - reset the cache for this mainScope
*/
getOptionScopes(mainScope: object, keyLists: string[][], resetCache?: boolean): any;
/**
* Returns the option scopes for resolving chart options
* @return {object[]}
*/
chartOptionScopes(): object[];
/**
* @param {object[]} scopes
* @param {string[]} names
* @param {function|object} context
* @param {string[]} [prefixes]
* @return {object}
*/
resolveNamedOptions(scopes: object[], names: string[], context: Function | object, prefixes?: string[]): object;
/**
* @param {object[]} scopes
* @param {object} [context]
* @param {string[]} [prefixes]
* @param {{scriptable: boolean, indexable: boolean, allKeys?: boolean}} [descriptorDefaults]
*/
createResolver(scopes: object[], context?: object, prefixes?: string[], descriptorDefaults?: {
scriptable: boolean;
indexable: boolean;
allKeys?: boolean;
}): any;
}

257
chartjs/dist/core/core.controller.d.ts vendored Normal file
View File

@ -0,0 +1,257 @@
export default Chart;
export type ChartEvent = import('../types/index.js').ChartEvent;
export type Point = import('../types/index.js').Point;
declare class Chart {
static defaults: import("./core.defaults.js").Defaults;
static instances: {};
static overrides: any;
static registry: import("./core.registry.js").Registry;
static version: string;
static getChart: (key: any) => any;
static register(...items: any[]): void;
static unregister(...items: any[]): void;
constructor(item: any, userConfig: any);
config: Config;
platform: any;
id: number;
ctx: any;
canvas: any;
width: any;
height: any;
_options: any;
_aspectRatio: any;
_layers: any[];
_metasets: any[];
_stacks: any;
boxes: any[];
currentDevicePixelRatio: any;
chartArea: any;
_active: any[];
_lastEvent: import("../types/index.js").ChartEvent;
_listeners: {};
/** @type {?{attach?: function, detach?: function, resize?: function}} */
_responsiveListeners: {
attach?: Function;
detach?: Function;
resize?: Function;
};
_sortedMetasets: any[];
scales: {};
_plugins: PluginService;
$proxies: {};
_hiddenIndices: {};
attached: boolean;
_animationsDisabled: boolean;
$context: {
chart: Chart;
type: string;
};
_doResize: (mode?: any) => number;
_dataChanges: any[];
get aspectRatio(): any;
set data(arg: any);
get data(): any;
set options(arg: any);
get options(): any;
get registry(): import("./core.registry.js").Registry;
/**
* @private
*/
private _initialize;
clear(): Chart;
stop(): Chart;
/**
* Resize the chart to its container or to explicit dimensions.
* @param {number} [width]
* @param {number} [height]
*/
resize(width?: number, height?: number): void;
_resizeBeforeDraw: {
width: number;
height: number;
};
_resize(width: any, height: any): void;
ensureScalesHaveIDs(): void;
/**
* Builds a map of scale ID to scale object for future lookup.
*/
buildOrUpdateScales(): void;
/**
* @private
*/
private _updateMetasets;
/**
* @private
*/
private _removeUnreferencedMetasets;
buildOrUpdateControllers(): any[];
/**
* Reset the elements of all datasets
* @private
*/
private _resetElements;
/**
* Resets the chart back to its state before the initial animation
*/
reset(): void;
update(mode: any): void;
_minPadding: number;
/**
* @private
*/
private _updateScales;
/**
* @private
*/
private _checkEventBindings;
/**
* @private
*/
private _updateHiddenIndices;
/**
* @private
*/
private _getUniformDataChanges;
/**
* Updates the chart layout unless a plugin returns `false` to the `beforeLayout`
* hook, in which case, plugins will not be called on `afterLayout`.
* @private
*/
private _updateLayout;
/**
* Updates all datasets unless a plugin returns `false` to the `beforeDatasetsUpdate`
* hook, in which case, plugins will not be called on `afterDatasetsUpdate`.
* @private
*/
private _updateDatasets;
/**
* Updates dataset at index unless a plugin returns `false` to the `beforeDatasetUpdate`
* hook, in which case, plugins will not be called on `afterDatasetUpdate`.
* @private
*/
private _updateDataset;
render(): void;
draw(): void;
/**
* @private
*/
private _getSortedDatasetMetas;
/**
* Gets the visible dataset metas in drawing order
* @return {object[]}
*/
getSortedVisibleDatasetMetas(): object[];
/**
* Draws all datasets unless a plugin returns `false` to the `beforeDatasetsDraw`
* hook, in which case, plugins will not be called on `afterDatasetsDraw`.
* @private
*/
private _drawDatasets;
/**
* Draws dataset at index unless a plugin returns `false` to the `beforeDatasetDraw`
* hook, in which case, plugins will not be called on `afterDatasetDraw`.
* @private
*/
private _drawDataset;
/**
* Checks whether the given point is in the chart area.
* @param {Point} point - in relative coordinates (see, e.g., getRelativePosition)
* @returns {boolean}
*/
isPointInArea(point: Point): boolean;
getElementsAtEventForMode(e: any, mode: any, options: any, useFinalPosition: any): any;
getDatasetMeta(datasetIndex: any): any;
getContext(): {
chart: Chart;
type: string;
};
getVisibleDatasetCount(): number;
isDatasetVisible(datasetIndex: any): boolean;
setDatasetVisibility(datasetIndex: any, visible: any): void;
toggleDataVisibility(index: any): void;
getDataVisibility(index: any): boolean;
/**
* @private
*/
private _updateVisibility;
hide(datasetIndex: any, dataIndex: any): void;
show(datasetIndex: any, dataIndex: any): void;
/**
* @private
*/
private _destroyDatasetMeta;
_stop(): void;
destroy(): void;
toBase64Image(...args: any[]): any;
/**
* @private
*/
private bindEvents;
/**
* @private
*/
private bindUserEvents;
/**
* @private
*/
private bindResponsiveEvents;
/**
* @private
*/
private unbindEvents;
updateHoverStyle(items: any, mode: any, enabled: any): void;
/**
* Get active (hovered) elements
* @returns array
*/
getActiveElements(): any[];
/**
* Set active (hovered) elements
* @param {array} activeElements New active data points
*/
setActiveElements(activeElements: any[]): void;
/**
* Calls enabled plugins on the specified hook and with the given args.
* This method immediately returns as soon as a plugin explicitly returns false. The
* returned value can be used, for instance, to interrupt the current action.
* @param {string} hook - The name of the plugin method to call (e.g. 'beforeUpdate').
* @param {Object} [args] - Extra arguments to apply to the hook call.
* @param {import('./core.plugins.js').filterCallback} [filter] - Filtering function for limiting which plugins are notified
* @returns {boolean} false if any of the plugins return false, else returns true.
*/
notifyPlugins(hook: string, args?: any, filter?: import('./core.plugins.js').filterCallback): boolean;
/**
* Check if a plugin with the specific ID is registered and enabled
* @param {string} pluginId - The ID of the plugin of which to check if it is enabled
* @returns {boolean}
*/
isPluginEnabled(pluginId: string): boolean;
/**
* @private
*/
private _updateHoverStyles;
/**
* @private
*/
private _eventHandler;
/**
* Handle an event
* @param {ChartEvent} e the event to handle
* @param {boolean} [replay] - true if the event was replayed by `update`
* @param {boolean} [inChartArea] - true if the event is inside chartArea
* @return {boolean} true if the chart needs to re-render
* @private
*/
private _handleEvent;
/**
* @param {ChartEvent} e - The event
* @param {import('../types/index.js').ActiveElement[]} lastActive - Previously active elements
* @param {boolean} inChartArea - Is the envent inside chartArea
* @param {boolean} useFinalPosition - Should the evaluation be done with current or final (after animation) element positions
* @returns {import('../types/index.js').ActiveElement[]} - The active elements
* @pravate
*/
_getActiveElements(e: ChartEvent, lastActive: import('../types/index.js').ActiveElement[], inChartArea: boolean, useFinalPosition: boolean): import('../types/index.js').ActiveElement[];
}
import Config from "./core.config.js";
import PluginService from "./core.plugins.js";

View File

@ -0,0 +1,251 @@
export default class DatasetController {
/**
* @type {any}
*/
static defaults: any;
/**
* Element type used to generate a meta dataset (e.g. Chart.element.LineElement).
*/
static datasetElementType: any;
/**
* Element type used to generate a meta data (e.g. Chart.element.PointElement).
*/
static dataElementType: any;
/**
* @param {Chart} chart
* @param {number} datasetIndex
*/
constructor(chart: Chart, datasetIndex: number);
chart: import("./core.controller.js").default;
_ctx: any;
index: number;
_cachedDataOpts: {};
_cachedMeta: any;
_type: any;
options: any;
/** @type {boolean | object} */
_parsing: boolean | object;
_data: any;
_objectData: any;
_sharedOptions: any;
_drawStart: any;
_drawCount: any;
enableOptionSharing: boolean;
supportsDecimation: boolean;
$context: any;
_syncList: any[];
datasetElementType: any;
dataElementType: any;
initialize(): void;
updateIndex(datasetIndex: any): void;
linkScales(): void;
getDataset(): any;
getMeta(): any;
/**
* @param {string} scaleID
* @return {Scale}
*/
getScaleForId(scaleID: string): Scale;
/**
* @private
*/
private _getOtherScale;
reset(): void;
/**
* @private
*/
private _destroy;
/**
* @private
*/
private _dataCheck;
addElements(): void;
buildOrUpdateElements(resetNewElements: any): void;
/**
* Merges user-supplied and default dataset-level options
* @private
*/
private configure;
/**
* @param {number} start
* @param {number} count
*/
parse(start: number, count: number): void;
/**
* Parse array of primitive values
* @param {object} meta - dataset meta
* @param {array} data - data array. Example [1,3,4]
* @param {number} start - start index
* @param {number} count - number of items to parse
* @returns {object} parsed item - item containing index and a parsed value
* for each scale id.
* Example: {xScale0: 0, yScale0: 1}
* @protected
*/
protected parsePrimitiveData(meta: object, data: any[], start: number, count: number): object;
/**
* Parse array of arrays
* @param {object} meta - dataset meta
* @param {array} data - data array. Example [[1,2],[3,4]]
* @param {number} start - start index
* @param {number} count - number of items to parse
* @returns {object} parsed item - item containing index and a parsed value
* for each scale id.
* Example: {x: 0, y: 1}
* @protected
*/
protected parseArrayData(meta: object, data: any[], start: number, count: number): object;
/**
* Parse array of objects
* @param {object} meta - dataset meta
* @param {array} data - data array. Example [{x:1, y:5}, {x:2, y:10}]
* @param {number} start - start index
* @param {number} count - number of items to parse
* @returns {object} parsed item - item containing index and a parsed value
* for each scale id. _custom is optional
* Example: {xScale0: 0, yScale0: 1, _custom: {r: 10, foo: 'bar'}}
* @protected
*/
protected parseObjectData(meta: object, data: any[], start: number, count: number): object;
/**
* @protected
*/
protected getParsed(index: any): any;
/**
* @protected
*/
protected getDataElement(index: any): any;
/**
* @protected
*/
protected applyStack(scale: any, parsed: any, mode: any): any;
/**
* @protected
*/
protected updateRangeFromParsed(range: any, scale: any, parsed: any, stack: any): void;
/**
* @protected
*/
protected getMinMax(scale: any, canStack: any): {
min: number;
max: number;
};
getAllParsedValues(scale: any): number[];
/**
* @return {number|boolean}
* @protected
*/
protected getMaxOverflow(): number | boolean;
/**
* @protected
*/
protected getLabelAndValue(index: any): {
label: string;
value: string;
};
/**
* @private
*/
private _update;
/**
* @param {string} mode
*/
update(mode: string): void;
draw(): void;
/**
* Returns a set of predefined style properties that should be used to represent the dataset
* or the data if the index is specified
* @param {number} index - data index
* @param {boolean} [active] - true if hover
* @return {object} style object
*/
getStyle(index: number, active?: boolean): object;
/**
* @protected
*/
protected getContext(index: any, active: any, mode: any): any;
/**
* @param {string} [mode]
* @protected
*/
protected resolveDatasetElementOptions(mode?: string): any;
/**
* @param {number} index
* @param {string} [mode]
* @protected
*/
protected resolveDataElementOptions(index: number, mode?: string): any;
/**
* @private
*/
private _resolveElementOptions;
/**
* @private
*/
private _resolveAnimations;
/**
* Utility for getting the options object shared between elements
* @protected
*/
protected getSharedOptions(options: any): any;
/**
* Utility for determining if `options` should be included in the updated properties
* @protected
*/
protected includeOptions(mode: any, sharedOptions: any): boolean;
/**
* @todo v4, rename to getSharedOptions and remove excess functions
*/
_getSharedOptions(start: any, mode: any): {
sharedOptions: any;
includeOptions: boolean;
};
/**
* Utility for updating an element with new properties, using animations when appropriate.
* @protected
*/
protected updateElement(element: any, index: any, properties: any, mode: any): void;
/**
* Utility to animate the shared options, that are potentially affecting multiple elements.
* @protected
*/
protected updateSharedOptions(sharedOptions: any, mode: any, newOptions: any): void;
/**
* @private
*/
private _setStyle;
removeHoverStyle(element: any, datasetIndex: any, index: any): void;
setHoverStyle(element: any, datasetIndex: any, index: any): void;
/**
* @private
*/
private _removeDatasetHoverStyle;
/**
* @private
*/
private _setDatasetHoverStyle;
/**
* @private
*/
private _resyncElements;
/**
* @private
*/
private _insertElements;
updateElements(element: any, start: any, count: any, mode: any): void;
/**
* @private
*/
private _removeElements;
/**
* @private
*/
private _sync;
_onDataPush(...args: any[]): void;
_onDataPop(): void;
_onDataShift(): void;
_onDataSplice(start: any, count: any, ...args: any[]): void;
_onDataUnshift(...args: any[]): void;
}
export type Chart = import('./core.controller.js').default;
export type Scale = import('./core.scale.js').default;

80
chartjs/dist/core/core.defaults.d.ts vendored Normal file
View File

@ -0,0 +1,80 @@
export const overrides: any;
export const descriptors: any;
/**
* Please use the module's default export which provides a singleton instance
* Note: class is exported for typedoc
*/
export class Defaults {
constructor(_descriptors: any, _appliers: any);
animation: any;
backgroundColor: string;
borderColor: string;
color: string;
datasets: {};
devicePixelRatio: (context: any) => any;
elements: {};
events: string[];
font: {
family: string;
size: number;
style: string;
lineHeight: number;
weight: any;
};
hover: {};
hoverBackgroundColor: (ctx: any, options: any) => CanvasGradient;
hoverBorderColor: (ctx: any, options: any) => CanvasGradient;
hoverColor: (ctx: any, options: any) => CanvasGradient;
indexAxis: string;
interaction: {
mode: string;
intersect: boolean;
includeInvisible: boolean;
};
maintainAspectRatio: boolean;
onHover: any;
onClick: any;
parsing: boolean;
plugins: {};
responsive: boolean;
scale: any;
scales: {};
showLine: boolean;
drawActiveElementsOnTop: boolean;
/**
* @param {string|object} scope
* @param {object} [values]
*/
set(scope: string | object, values?: object): any;
/**
* @param {string} scope
*/
get(scope: string): any;
/**
* @param {string|object} scope
* @param {object} [values]
*/
describe(scope: string | object, values?: object): any;
override(scope: any, values: any): any;
/**
* Routes the named defaults to fallback to another scope/name.
* This routing is useful when those target values, like defaults.color, are changed runtime.
* If the values would be copied, the runtime change would not take effect. By routing, the
* fallback is evaluated at each access, so its always up to date.
*
* Example:
*
* defaults.route('elements.arc', 'backgroundColor', '', 'color')
* - reads the backgroundColor from defaults.color when undefined locally
*
* @param {string} scope Scope this route applies to.
* @param {string} name Property name that should be routed to different namespace when not defined here.
* @param {string} targetScope The namespace where those properties should be routed to.
* Empty string ('') is the root of defaults.
* @param {string} targetName The target name in the target scope the property should be routed to.
*/
route(scope: string, name: string, targetScope: string, targetName: string): void;
apply(appliers: any): void;
}
declare const _default: Defaults;
export default _default;

21
chartjs/dist/core/core.element.d.ts vendored Normal file
View File

@ -0,0 +1,21 @@
import type { AnyObject } from '../types/basic.js';
import type { Point } from '../types/geometric.js';
import type { Animation } from '../types/animation.js';
export default class Element<T = AnyObject, O = AnyObject> {
static defaults: {};
static defaultRoutes: any;
x: number;
y: number;
active: boolean;
options: O;
$animations: Record<keyof T, Animation>;
tooltipPosition(useFinalPosition: boolean): Point;
hasValue(): boolean;
/**
* Gets the current or final value of each prop. Can return extra properties (whole object).
* @param props - properties to get
* @param [final] - get the final value (animation target)
*/
getProps<P extends (keyof T)[]>(props: P, final?: boolean): Pick<T, P[number]>;
getProps<P extends string>(props: P[], final?: boolean): Partial<Record<P, unknown>>;
}

92
chartjs/dist/core/core.interaction.d.ts vendored Normal file
View File

@ -0,0 +1,92 @@
declare namespace _default {
export { evaluateInteractionItems };
export namespace modes {
/**
* Returns items at the same index. If the options.intersect parameter is true, we only return items if we intersect something
* If the options.intersect mode is false, we find the nearest item and return the items at the same index as that item
* @function Chart.Interaction.modes.index
* @since v2.4.0
* @param {Chart} chart - the chart we are returning items from
* @param {Event} e - the event we are find things at
* @param {InteractionOptions} options - options to use
* @param {boolean} [useFinalPosition] - use final element position (animation target)
* @return {InteractionItem[]} - items that are found
*/
function index(chart: import("./core.controller.js").default, e: Event, options: InteractionOptions, useFinalPosition?: boolean): InteractionItem[];
/**
* Returns items in the same dataset. If the options.intersect parameter is true, we only return items if we intersect something
* If the options.intersect is false, we find the nearest item and return the items in that dataset
* @function Chart.Interaction.modes.dataset
* @param {Chart} chart - the chart we are returning items from
* @param {Event} e - the event we are find things at
* @param {InteractionOptions} options - options to use
* @param {boolean} [useFinalPosition] - use final element position (animation target)
* @return {InteractionItem[]} - items that are found
*/
function dataset(chart: import("./core.controller.js").default, e: Event, options: InteractionOptions, useFinalPosition?: boolean): InteractionItem[];
/**
* Point mode returns all elements that hit test based on the event position
* of the event
* @function Chart.Interaction.modes.intersect
* @param {Chart} chart - the chart we are returning items from
* @param {Event} e - the event we are find things at
* @param {InteractionOptions} options - options to use
* @param {boolean} [useFinalPosition] - use final element position (animation target)
* @return {InteractionItem[]} - items that are found
*/
function point(chart: import("./core.controller.js").default, e: Event, options: InteractionOptions, useFinalPosition?: boolean): InteractionItem[];
/**
* nearest mode returns the element closest to the point
* @function Chart.Interaction.modes.intersect
* @param {Chart} chart - the chart we are returning items from
* @param {Event} e - the event we are find things at
* @param {InteractionOptions} options - options to use
* @param {boolean} [useFinalPosition] - use final element position (animation target)
* @return {InteractionItem[]} - items that are found
*/
function nearest(chart: import("./core.controller.js").default, e: Event, options: InteractionOptions, useFinalPosition?: boolean): InteractionItem[];
/**
* x mode returns the elements that hit-test at the current x coordinate
* @function Chart.Interaction.modes.x
* @param {Chart} chart - the chart we are returning items from
* @param {Event} e - the event we are find things at
* @param {InteractionOptions} options - options to use
* @param {boolean} [useFinalPosition] - use final element position (animation target)
* @return {InteractionItem[]} - items that are found
*/
function x(chart: import("./core.controller.js").default, e: Event, options: InteractionOptions, useFinalPosition?: boolean): InteractionItem[];
/**
* y mode returns the elements that hit-test at the current y coordinate
* @function Chart.Interaction.modes.y
* @param {Chart} chart - the chart we are returning items from
* @param {Event} e - the event we are find things at
* @param {InteractionOptions} options - options to use
* @param {boolean} [useFinalPosition] - use final element position (animation target)
* @return {InteractionItem[]} - items that are found
*/
function y(chart: import("./core.controller.js").default, e: Event, options: InteractionOptions, useFinalPosition?: boolean): InteractionItem[];
}
}
export default _default;
export type Chart = import('./core.controller.js').default;
export type ChartEvent = import('../types/index.js').ChartEvent;
export type InteractionOptions = {
axis?: string;
intersect?: boolean;
includeInvisible?: boolean;
};
export type InteractionItem = {
datasetIndex: number;
index: number;
element: import('./core.element.js').default;
};
export type Point = import('../types/index.js').Point;
/**
* Helper function to select candidate elements for interaction
* @param {Chart} chart - the chart
* @param {string} axis - the axis mode. x|y|xy|r
* @param {Point} position - the point to be nearest to, in relative coordinates
* @param {function} handler - the callback to execute for each visible item
* @param {boolean} [intersect] - consider intersecting items
*/
declare function evaluateInteractionItems(chart: Chart, axis: string, position: Point, handler: Function, intersect?: boolean): void;

88
chartjs/dist/core/core.layouts.d.ts vendored Normal file
View File

@ -0,0 +1,88 @@
declare namespace _default {
/**
* Register a box to a chart.
* A box is simply a reference to an object that requires layout. eg. Scales, Legend, Title.
* @param {Chart} chart - the chart to use
* @param {LayoutItem} item - the item to add to be laid out
*/
function addBox(chart: import("./core.controller.js").default, item: LayoutItem): void;
/**
* Remove a layoutItem from a chart
* @param {Chart} chart - the chart to remove the box from
* @param {LayoutItem} layoutItem - the item to remove from the layout
*/
function removeBox(chart: import("./core.controller.js").default, layoutItem: LayoutItem): void;
/**
* Sets (or updates) options on the given `item`.
* @param {Chart} chart - the chart in which the item lives (or will be added to)
* @param {LayoutItem} item - the item to configure with the given options
* @param {object} options - the new item options.
*/
function configure(chart: import("./core.controller.js").default, item: LayoutItem, options: any): void;
/**
* Fits boxes of the given chart into the given size by having each box measure itself
* then running a fitting algorithm
* @param {Chart} chart - the chart
* @param {number} width - the width to fit into
* @param {number} height - the height to fit into
* @param {number} minPadding - minimum padding required for each side of chart area
*/
function update(chart: import("./core.controller.js").default, width: number, height: number, minPadding: number): void;
}
export default _default;
export type Chart = import('./core.controller.js').default;
export type LayoutItem = {
/**
* - The position of the item in the chart layout. Possible values are
* 'left', 'top', 'right', 'bottom', and 'chartArea'
*/
position: string;
/**
* - The weight used to sort the item. Higher weights are further away from the chart area
*/
weight: number;
/**
* - if true, and the item is horizontal, then push vertical boxes down
*/
fullSize: boolean;
/**
* - returns true if the layout item is horizontal (ie. top or bottom)
*/
isHorizontal: Function;
/**
* - Takes two parameters: width and height. Returns size of item
*/
update: Function;
/**
* - Draws the element
*/
draw: Function;
/**
* - Returns an object with padding on the edges
*/
getPadding?: Function;
/**
* - Width of item. Must be valid after update()
*/
width: number;
/**
* - Height of item. Must be valid after update()
*/
height: number;
/**
* - Left edge of the item. Set by layout system and cannot be used in update
*/
left: number;
/**
* - Top edge of the item. Set by layout system and cannot be used in update
*/
top: number;
/**
* - Right edge of the item. Set by layout system and cannot be used in update
*/
right: number;
/**
* - Bottom edge of the item. Set by layout system and cannot be used in update
*/
bottom: number;
};

View File

@ -0,0 +1 @@
export function applyLayoutsDefaults(defaults: any): void;

61
chartjs/dist/core/core.plugins.d.ts vendored Normal file
View File

@ -0,0 +1,61 @@
/**
* @typedef { import('./core.controller.js').default } Chart
* @typedef { import('../types/index.js').ChartEvent } ChartEvent
* @typedef { import('../plugins/plugin.tooltip.js').default } Tooltip
*/
/**
* @callback filterCallback
* @param {{plugin: object, options: object}} value
* @param {number} [index]
* @param {array} [array]
* @param {object} [thisArg]
* @return {boolean}
*/
export default class PluginService {
_init: any[];
/**
* Calls enabled plugins for `chart` on the specified hook and with the given args.
* This method immediately returns as soon as a plugin explicitly returns false. The
* returned value can be used, for instance, to interrupt the current action.
* @param {Chart} chart - The chart instance for which plugins should be called.
* @param {string} hook - The name of the plugin method to call (e.g. 'beforeUpdate').
* @param {object} [args] - Extra arguments to apply to the hook call.
* @param {filterCallback} [filter] - Filtering function for limiting which plugins are notified
* @returns {boolean} false if any of the plugins return false, else returns true.
*/
notify(chart: Chart, hook: string, args?: object, filter?: filterCallback): boolean;
/**
* @private
*/
private _notify;
invalidate(): void;
_oldCache: {
plugin: any;
options: any;
}[];
_cache: {
plugin: any;
options: any;
}[];
/**
* @param {Chart} chart
* @private
*/
private _descriptors;
_createDescriptors(chart: any, all: any): {
plugin: any;
options: any;
}[];
/**
* @param {Chart} chart
* @private
*/
private _notifyStateChanges;
}
export type Chart = import('./core.controller.js').default;
export type ChartEvent = import('../types/index.js').ChartEvent;
export type Tooltip = any;
export type filterCallback = (value: {
plugin: object;
options: object;
}, index?: number, array?: any[], thisArg?: object) => boolean;

90
chartjs/dist/core/core.registry.d.ts vendored Normal file
View File

@ -0,0 +1,90 @@
/**
* Please use the module's default export which provides a singleton instance
* Note: class is exported for typedoc
*/
export class Registry {
controllers: TypedRegistry;
elements: TypedRegistry;
plugins: TypedRegistry;
scales: TypedRegistry;
_typedRegistries: TypedRegistry[];
/**
* @param {...any} args
*/
add(...args: any[]): void;
remove(...args: any[]): void;
/**
* @param {...typeof DatasetController} args
*/
addControllers(...args: (typeof DatasetController)[]): void;
/**
* @param {...typeof Element} args
*/
addElements(...args: (typeof Element)[]): void;
/**
* @param {...any} args
*/
addPlugins(...args: any[]): void;
/**
* @param {...typeof Scale} args
*/
addScales(...args: (typeof Scale)[]): void;
/**
* @param {string} id
* @returns {typeof DatasetController}
*/
getController(id: string): typeof DatasetController;
/**
* @param {string} id
* @returns {typeof Element}
*/
getElement(id: string): typeof Element;
/**
* @param {string} id
* @returns {object}
*/
getPlugin(id: string): object;
/**
* @param {string} id
* @returns {typeof Scale}
*/
getScale(id: string): typeof Scale;
/**
* @param {...typeof DatasetController} args
*/
removeControllers(...args: (typeof DatasetController)[]): void;
/**
* @param {...typeof Element} args
*/
removeElements(...args: (typeof Element)[]): void;
/**
* @param {...any} args
*/
removePlugins(...args: any[]): void;
/**
* @param {...typeof Scale} args
*/
removeScales(...args: (typeof Scale)[]): void;
/**
* @private
*/
private _each;
/**
* @private
*/
private _exec;
/**
* @private
*/
private _getRegistryForType;
/**
* @private
*/
private _get;
}
declare const _default: Registry;
export default _default;
import TypedRegistry from "./core.typedRegistry.js";
import DatasetController from "./core.datasetController.js";
import Element from "./core.element.js";
import Scale from "./core.scale.js";

View File

@ -0,0 +1,19 @@
/**
* @typedef { import('./core.controller.js').default } Chart
* @typedef {{value:number | string, label?:string, major?:boolean, $context?:any}} Tick
*/
/**
* Returns a subset of ticks to be plotted to avoid overlapping labels.
* @param {import('./core.scale.js').default} scale
* @param {Tick[]} ticks
* @return {Tick[]}
* @private
*/
export function autoSkip(scale: import('./core.scale.js').default, ticks: Tick[]): Tick[];
export type Chart = import('./core.controller.js').default;
export type Tick = {
value: number | string;
label?: string;
major?: boolean;
$context?: any;
};

343
chartjs/dist/core/core.scale.d.ts vendored Normal file
View File

@ -0,0 +1,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";

View File

@ -0,0 +1 @@
export function applyScaleDefaults(defaults: any): void;

31
chartjs/dist/core/core.ticks.d.ts vendored Normal file
View File

@ -0,0 +1,31 @@
declare namespace _default {
export { formatters };
}
export default _default;
declare namespace formatters {
/**
* Formatter for value labels
* @method Chart.Ticks.formatters.values
* @param value the value to display
* @return {string|string[]} the label to display
*/
function values(value: any): string | string[];
/**
* Formatter for numeric ticks
* @method Chart.Ticks.formatters.numeric
* @param tickValue {number} the value to be formatted
* @param index {number} the position of the tickValue parameter in the ticks array
* @param ticks {object[]} the list of ticks being converted
* @return {string} string representation of the tickValue parameter
*/
function numeric(tickValue: number, index: number, ticks: any[]): string;
/**
* Formatter for logarithmic ticks
* @method Chart.Ticks.formatters.logarithmic
* @param tickValue {number} the value to be formatted
* @param index {number} the position of the tickValue parameter in the ticks array
* @param ticks {object[]} the list of ticks being converted
* @return {string} string representation of the tickValue parameter
*/
function logarithmic(tickValue: number, index: number, ticks: any[]): string;
}

View File

@ -0,0 +1,33 @@
/**
* @typedef {{id: string, defaults: any, overrides?: any, defaultRoutes: any}} IChartComponent
*/
export default class TypedRegistry {
constructor(type: any, scope: any, override: any);
type: any;
scope: any;
override: any;
items: any;
isForType(type: any): boolean;
/**
* @param {IChartComponent} item
* @returns {string} The scope where items defaults were registered to.
*/
register(item: IChartComponent): string;
/**
* @param {string} id
* @returns {object?}
*/
get(id: string): object | null;
/**
* @param {IChartComponent} item
*/
unregister(item: IChartComponent): void;
}
export type IChartComponent = {
id: string;
defaults: any;
overrides?: any;
defaultRoutes: any;
};
import defaults from "./core.defaults.js";
import { overrides } from "./core.defaults.js";

15
chartjs/dist/core/index.d.ts vendored Normal file
View File

@ -0,0 +1,15 @@
export type { DateAdapter, TimeUnit } from './core.adapters.js';
export { default as _adapters } from './core.adapters.js';
export { default as Animation } from './core.animation.js';
export { default as Animations } from './core.animations.js';
export { default as animator } from './core.animator.js';
export { default as Chart } from './core.controller.js';
export { default as DatasetController } from './core.datasetController.js';
export { default as defaults } from './core.defaults.js';
export { default as Element } from './core.element.js';
export { default as Interaction } from './core.interaction.js';
export { default as layouts } from './core.layouts.js';
export { default as plugins } from './core.plugins.js';
export { default as registry } from './core.registry.js';
export { default as Scale } from './core.scale.js';
export { default as Ticks } from './core.ticks.js';