trying to add chartjs and fix data passing

This commit is contained in:
forest 2023-01-07 16:48:11 -06:00
parent bb46636bf1
commit 581c0644bc
109 changed files with 36402 additions and 7 deletions

View file

@ -78,10 +78,10 @@ func initFrontend(config *Config) FrontendApp {
}
panelTemplateData := struct {
DiskUsage string
DBTableSizes string
RowCountByRoom string
}{string(diskUsage), string(dbTableSizes), string(rowCountByRoom)}
DiskUsage template.JS
DBTableSizes template.JS
RowCountByRoom template.JS
}{template.JS(diskUsage), template.JS(dbTableSizes), template.JS(rowCountByRoom)}
app.buildPageFromTemplate(responseWriter, request, session, "panel.html", panelTemplateData)
} else {

View file

@ -1,8 +1,9 @@
<script src="static/vendor/chartjs/chart.js"></script>
<script>
const diskUsage = {{ .DiskUsage }};
const dbTableSizes = {{ .DBTableSizes }};
const RowCountByRoom = {{ .RowCountByRoom }};
</script>

11362
frontend/static/vendor/chartjs/chart.cjs vendored Normal file

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

11315
frontend/static/vendor/chartjs/chart.js vendored Normal file

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,62 @@
export default class BarController extends DatasetController {
static id: string;
/**
* @type {any}
*/
static overrides: any;
/**
* Overriding primitive data parsing since we support mixed primitive/array
* data for float bars
* @protected
*/
protected parsePrimitiveData(meta: any, data: any, start: any, count: any): any[];
/**
* Overriding array data parsing since we support mixed primitive/array
* data for float bars
* @protected
*/
protected parseArrayData(meta: any, data: any, start: any, count: any): any[];
/**
* Overriding object data parsing since we support mixed primitive/array
* value-scale data for float bars
* @protected
*/
protected parseObjectData(meta: any, data: any, start: any, count: any): any[];
update(mode: any): void;
/**
* Returns the stacks based on groups and bar visibility.
* @param {number} [last] - The dataset index
* @param {number} [dataIndex] - The data index of the ruler
* @returns {string[]} The list of stack IDs
* @private
*/
private _getStacks;
/**
* Returns the effective number of stacks based on groups and bar visibility.
* @private
*/
private _getStackCount;
/**
* Returns the stack index for the given dataset based on groups and bar visibility.
* @param {number} [datasetIndex] - The dataset index
* @param {string} [name] - The stack name to find
* @param {number} [dataIndex]
* @returns {number} The stack index
* @private
*/
private _getStackIndex;
/**
* @private
*/
private _getRuler;
/**
* Note: pixel values are not clamped to the scale area.
* @private
*/
private _calculateBarValuePixels;
/**
* @private
*/
private _calculateBarIndexPixels;
}
import DatasetController from "../core/core.datasetController.js";

View file

@ -0,0 +1,35 @@
export default class BubbleController extends DatasetController {
static id: string;
/**
* @type {any}
*/
static overrides: any;
/**
* Parse array of primitive values
* @protected
*/
protected parsePrimitiveData(meta: any, data: any, start: any, count: any): any;
/**
* Parse array of arrays
* @protected
*/
protected parseArrayData(meta: any, data: any, start: any, count: any): any;
/**
* Parse array of objects
* @protected
*/
protected parseObjectData(meta: any, data: any, start: any, count: any): any;
/**
* @protected
*/
protected getMaxOverflow(): number;
/**
* @protected
*/
protected getLabelAndValue(index: any): {
label: any;
value: string;
};
update(mode: any): void;
}
import DatasetController from "../core/core.datasetController.js";

View file

@ -0,0 +1,64 @@
export default class DoughnutController extends DatasetController {
static id: string;
static descriptors: {
_scriptable: (name: any) => boolean;
_indexable: (name: any) => boolean;
};
/**
* @type {any}
*/
static overrides: any;
constructor(chart: any, datasetIndex: any);
innerRadius: number;
outerRadius: number;
offsetX: number;
offsetY: number;
/**
* Override data parsing, since we are not using scales
*/
parse(start: any, count: any): void;
/**
* @private
*/
private _getRotation;
/**
* @private
*/
private _getCircumference;
/**
* Get the maximal rotation & circumference extents
* across all visible datasets.
*/
_getRotationExtents(): {
rotation: number;
circumference: number;
};
/**
* @private
*/
private _circumference;
calculateTotal(): number;
calculateCircumference(value: any): number;
getLabelAndValue(index: any): {
label: any;
value: string;
};
getMaxBorderWidth(arcs: any): number;
getMaxOffset(arcs: any): number;
/**
* Get radius length offset of the dataset in relation to the visible datasets weights. This allows determining the inner and outer radius correctly
* @private
*/
private _getRingWeightOffset;
/**
* @private
*/
private _getRingWeight;
/**
* Returns the sum of all visible data set weights.
* @private
*/
private _getVisibleDatasetWeightTotal;
}
export type Chart = import('../core/core.controller.js').default;
import DatasetController from "../core/core.datasetController.js";

View file

@ -0,0 +1,13 @@
export default class LineController extends DatasetController {
static id: string;
/**
* @type {any}
*/
static overrides: any;
update(mode: any): void;
/**
* @protected
*/
protected getMaxOverflow(): any;
}
import DatasetController from "../core/core.datasetController.js";

View file

@ -0,0 +1,3 @@
export default class PieController extends DoughnutController {
}
import DoughnutController from "./controller.doughnut.js";

View file

@ -0,0 +1,33 @@
export default class PolarAreaController extends DatasetController {
static id: string;
/**
* @type {any}
*/
static overrides: any;
constructor(chart: any, datasetIndex: any);
innerRadius: number;
outerRadius: number;
getLabelAndValue(index: any): {
label: any;
value: string;
};
parseObjectData(meta: any, data: any, start: any, count: any): any[];
update(mode: any): void;
/**
* @protected
*/
protected getMinMax(): {
min: number;
max: number;
};
/**
* @private
*/
private _updateRadius;
countVisibleElements(): number;
/**
* @private
*/
private _computeAngle;
}
import DatasetController from "../core/core.datasetController.js";

View file

@ -0,0 +1,17 @@
export default class RadarController extends DatasetController {
static id: string;
/**
* @type {any}
*/
static overrides: any;
/**
* @protected
*/
protected getLabelAndValue(index: any): {
label: any;
value: string;
};
parseObjectData(meta: any, data: any, start: any, count: any): any[];
update(mode: any): void;
}
import DatasetController from "../core/core.datasetController.js";

View file

@ -0,0 +1,20 @@
export default class ScatterController extends DatasetController {
static id: string;
/**
* @type {any}
*/
static overrides: any;
/**
* @protected
*/
protected getLabelAndValue(index: any): {
label: any;
value: string;
};
update(mode: any): void;
/**
* @protected
*/
protected getMaxOverflow(): any;
}
import DatasetController from "../core/core.datasetController.js";

View file

@ -0,0 +1,8 @@
export { default as BarController } from "./controller.bar.js";
export { default as BubbleController } from "./controller.bubble.js";
export { default as DoughnutController } from "./controller.doughnut.js";
export { default as LineController } from "./controller.line.js";
export { default as PolarAreaController } from "./controller.polarArea.js";
export { default as PieController } from "./controller.pie.js";
export { default as RadarController } from "./controller.radar.js";
export { default as ScatterController } from "./controller.scatter.js";

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 declare 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;

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;
}

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;

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;

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;
}

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;

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;

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>>;
}

View file

@ -0,0 +1,156 @@
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 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[];
/**
* 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[];
/**
* 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[];
/**
* 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[];
/**
* 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[];
/**
* 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;

View file

@ -0,0 +1,117 @@
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;
/**
* 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;
/**
* 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;
/**
* 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;
/**
* 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;

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;

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;
};

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?: any): 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('./core.controller.js').default;
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;

View file

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

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';

View file

@ -0,0 +1,44 @@
import Element from '../core/core.element.js';
import type { ArcOptions, Point } from '../types/index.js';
export interface ArcProps extends Point {
startAngle: number;
endAngle: number;
innerRadius: number;
outerRadius: number;
circumference: number;
}
export default class ArcElement extends Element<ArcProps, ArcOptions> {
static id: string;
static defaults: {
borderAlign: string;
borderColor: string;
borderJoinStyle: any;
borderRadius: number;
borderWidth: number;
offset: number;
spacing: number;
angle: any;
circular: boolean;
};
static defaultRoutes: {
backgroundColor: string;
};
circumference: number;
endAngle: number;
fullCircles: number;
innerRadius: number;
outerRadius: number;
pixelMargin: number;
startAngle: number;
constructor(cfg: any);
inRange(chartX: number, chartY: number, useFinalPosition: boolean): boolean;
getCenterPoint(useFinalPosition: boolean): {
x: number;
y: number;
};
tooltipPosition(useFinalPosition: boolean): {
x: number;
y: number;
};
draw(ctx: CanvasRenderingContext2D): void;
}

View file

@ -0,0 +1,32 @@
export default class BarElement extends Element<import("../types/basic.js").AnyObject, import("../types/basic.js").AnyObject> {
static id: string;
/**
* @type {any}
*/
static defaults: any;
constructor(cfg: any);
options: any;
horizontal: any;
base: any;
width: any;
height: any;
inflateAmount: any;
draw(ctx: any): void;
inRange(mouseX: any, mouseY: any, useFinalPosition: any): boolean;
inXRange(mouseX: any, useFinalPosition: any): boolean;
inYRange(mouseY: any, useFinalPosition: any): boolean;
getCenterPoint(useFinalPosition: any): {
x: number;
y: number;
};
getRange(axis: any): number;
}
export type BarProps = {
x: number;
y: number;
base: number;
horizontal: boolean;
width: number;
height: number;
};
import Element from "../core/core.element.js";

View file

@ -0,0 +1,87 @@
export default class LineElement extends Element<import("../types/basic.js").AnyObject, import("../types/basic.js").AnyObject> {
static id: string;
/**
* @type {any}
*/
static defaults: any;
static descriptors: {
_scriptable: boolean;
_indexable: (name: any) => boolean;
};
constructor(cfg: any);
animated: boolean;
options: any;
_chart: any;
_loop: any;
_fullLoop: any;
_path: any;
_points: any;
_segments: import("../helpers/helpers.segment.js").Segment[];
_decimated: boolean;
_pointsUpdated: boolean;
_datasetIndex: any;
updateControlPoints(chartArea: any, indexAxis: any): void;
set points(arg: any);
get points(): any;
get segments(): import("../helpers/helpers.segment.js").Segment[];
/**
* First non-skipped point on this line
* @returns {PointElement|undefined}
*/
first(): PointElement | undefined;
/**
* Last non-skipped point on this line
* @returns {PointElement|undefined}
*/
last(): PointElement | undefined;
/**
* Interpolate a point in this line at the same value on `property` as
* the reference `point` provided
* @param {PointElement} point - the reference point
* @param {string} property - the property to match on
* @returns {PointElement|undefined}
*/
interpolate(point: PointElement, property: string): PointElement | undefined;
/**
* Append a segment of this line to current path.
* @param {CanvasRenderingContext2D} ctx
* @param {object} segment
* @param {number} segment.start - start index of the segment, referring the points array
* @param {number} segment.end - end index of the segment, referring the points array
* @param {boolean} segment.loop - indicates that the segment is a loop
* @param {object} params
* @param {boolean} params.move - move to starting point (vs line to it)
* @param {boolean} params.reverse - path the segment from end to start
* @param {number} params.start - limit segment to points starting from `start` index
* @param {number} params.end - limit segment to points ending at `start` + `count` index
* @returns {undefined|boolean} - true if the segment is a full loop (path should be closed)
*/
pathSegment(ctx: CanvasRenderingContext2D, segment: {
start: number;
end: number;
loop: boolean;
}, params: {
move: boolean;
reverse: boolean;
start: number;
end: number;
}): undefined | boolean;
/**
* Append all segments of this line to current path.
* @param {CanvasRenderingContext2D|Path2D} ctx
* @param {number} [start]
* @param {number} [count]
* @returns {undefined|boolean} - true if line is a full loop (path should be closed)
*/
path(ctx: CanvasRenderingContext2D | Path2D, start?: number, count?: number): undefined | boolean;
/**
* Draw
* @param {CanvasRenderingContext2D} ctx
* @param {object} chartArea
* @param {number} [start]
* @param {number} [count]
*/
draw(ctx: CanvasRenderingContext2D, chartArea: object, start?: number, count?: number): void;
}
export type PointElement = import('./element.point.js').default;
import Element from "../core/core.element.js";

View file

@ -0,0 +1,39 @@
import Element from '../core/core.element.js';
import type { CartesianParsedData, ChartArea, Point, PointHoverOptions, PointOptions } from '../types/index.js';
export declare type PointProps = Point;
export default class PointElement extends Element<PointProps, PointOptions & PointHoverOptions> {
static id: string;
parsed: CartesianParsedData;
skip?: boolean;
stop?: boolean;
/**
* @type {any}
*/
static defaults: {
borderWidth: number;
hitRadius: number;
hoverBorderWidth: number;
hoverRadius: number;
pointStyle: string;
radius: number;
rotation: number;
};
/**
* @type {any}
*/
static defaultRoutes: {
backgroundColor: string;
borderColor: string;
};
constructor(cfg: any);
inRange(mouseX: number, mouseY: number, useFinalPosition?: boolean): boolean;
inXRange(mouseX: number, useFinalPosition?: boolean): boolean;
inYRange(mouseY: number, useFinalPosition?: boolean): boolean;
getCenterPoint(useFinalPosition?: boolean): {
x: number;
y: number;
};
size(options?: Partial<PointOptions & PointHoverOptions>): number;
draw(ctx: CanvasRenderingContext2D, area: ChartArea): void;
getRange(): any;
}

View file

@ -0,0 +1,4 @@
export { default as ArcElement } from "./element.arc.js";
export { default as LineElement } from "./element.line.js";
export { default as PointElement } from "./element.point.js";
export { default as BarElement } from "./element.bar.js";

View file

@ -0,0 +1,135 @@
/*!
* Chart.js v4.1.2
* https://www.chartjs.org
* (c) 2023 Chart.js Contributors
* Released under the MIT License
*/
'use strict';
var helpers_segment = require('./chunks/helpers.segment.cjs');
require('@kurkle/color');
exports.HALF_PI = helpers_segment.HALF_PI;
exports.INFINITY = helpers_segment.INFINITY;
exports.PI = helpers_segment.PI;
exports.PITAU = helpers_segment.PITAU;
exports.QUARTER_PI = helpers_segment.QUARTER_PI;
exports.RAD_PER_DEG = helpers_segment.RAD_PER_DEG;
exports.TAU = helpers_segment.TAU;
exports.TWO_THIRDS_PI = helpers_segment.TWO_THIRDS_PI;
exports._addGrace = helpers_segment._addGrace;
exports._alignPixel = helpers_segment._alignPixel;
exports._alignStartEnd = helpers_segment._alignStartEnd;
exports._angleBetween = helpers_segment._angleBetween;
exports._angleDiff = helpers_segment._angleDiff;
exports._arrayUnique = helpers_segment._arrayUnique;
exports._attachContext = helpers_segment._attachContext;
exports._bezierCurveTo = helpers_segment._bezierCurveTo;
exports._bezierInterpolation = helpers_segment._bezierInterpolation;
exports._boundSegment = helpers_segment._boundSegment;
exports._boundSegments = helpers_segment._boundSegments;
exports._capitalize = helpers_segment._capitalize;
exports._computeSegments = helpers_segment._computeSegments;
exports._createResolver = helpers_segment._createResolver;
exports._decimalPlaces = helpers_segment._decimalPlaces;
exports._deprecated = helpers_segment._deprecated;
exports._descriptors = helpers_segment._descriptors;
exports._elementsEqual = helpers_segment._elementsEqual;
exports._factorize = helpers_segment._factorize;
exports._filterBetween = helpers_segment._filterBetween;
exports._getParentNode = helpers_segment._getParentNode;
exports._getStartAndCountOfVisiblePoints = helpers_segment._getStartAndCountOfVisiblePoints;
exports._int16Range = helpers_segment._int16Range;
exports._isBetween = helpers_segment._isBetween;
exports._isClickEvent = helpers_segment._isClickEvent;
exports._isDomSupported = helpers_segment._isDomSupported;
exports._isPointInArea = helpers_segment._isPointInArea;
exports._limitValue = helpers_segment._limitValue;
exports._longestText = helpers_segment._longestText;
exports._lookup = helpers_segment._lookup;
exports._lookupByKey = helpers_segment._lookupByKey;
exports._measureText = helpers_segment._measureText;
exports._merger = helpers_segment._merger;
exports._mergerIf = helpers_segment._mergerIf;
exports._normalizeAngle = helpers_segment._normalizeAngle;
exports._parseObjectDataRadialScale = helpers_segment._parseObjectDataRadialScale;
exports._pointInLine = helpers_segment._pointInLine;
exports._readValueToProps = helpers_segment._readValueToProps;
exports._rlookupByKey = helpers_segment._rlookupByKey;
exports._scaleRangesChanged = helpers_segment._scaleRangesChanged;
exports._setMinAndMaxByKey = helpers_segment._setMinAndMaxByKey;
exports._splitKey = helpers_segment._splitKey;
exports._steppedInterpolation = helpers_segment._steppedInterpolation;
exports._steppedLineTo = helpers_segment._steppedLineTo;
exports._textX = helpers_segment._textX;
exports._toLeftRightCenter = helpers_segment._toLeftRightCenter;
exports._updateBezierControlPoints = helpers_segment._updateBezierControlPoints;
exports.addRoundedRectPath = helpers_segment.addRoundedRectPath;
exports.almostEquals = helpers_segment.almostEquals;
exports.almostWhole = helpers_segment.almostWhole;
exports.callback = helpers_segment.callback;
exports.clearCanvas = helpers_segment.clearCanvas;
exports.clipArea = helpers_segment.clipArea;
exports.clone = helpers_segment.clone;
exports.color = helpers_segment.color;
exports.createContext = helpers_segment.createContext;
exports.debounce = helpers_segment.debounce;
exports.defined = helpers_segment.defined;
exports.distanceBetweenPoints = helpers_segment.distanceBetweenPoints;
exports.drawPoint = helpers_segment.drawPoint;
exports.drawPointLegend = helpers_segment.drawPointLegend;
exports.each = helpers_segment.each;
exports.easingEffects = helpers_segment.effects;
exports.finiteOrDefault = helpers_segment.finiteOrDefault;
exports.fontString = helpers_segment.fontString;
exports.formatNumber = helpers_segment.formatNumber;
exports.getAngleFromPoint = helpers_segment.getAngleFromPoint;
exports.getHoverColor = helpers_segment.getHoverColor;
exports.getMaximumSize = helpers_segment.getMaximumSize;
exports.getRelativePosition = helpers_segment.getRelativePosition;
exports.getRtlAdapter = helpers_segment.getRtlAdapter;
exports.getStyle = helpers_segment.getStyle;
exports.isArray = helpers_segment.isArray;
exports.isFinite = helpers_segment.isNumberFinite;
exports.isFunction = helpers_segment.isFunction;
exports.isNullOrUndef = helpers_segment.isNullOrUndef;
exports.isNumber = helpers_segment.isNumber;
exports.isObject = helpers_segment.isObject;
exports.isPatternOrGradient = helpers_segment.isPatternOrGradient;
exports.listenArrayEvents = helpers_segment.listenArrayEvents;
exports.log10 = helpers_segment.log10;
exports.merge = helpers_segment.merge;
exports.mergeIf = helpers_segment.mergeIf;
exports.niceNum = helpers_segment.niceNum;
exports.noop = helpers_segment.noop;
exports.overrideTextDirection = helpers_segment.overrideTextDirection;
exports.readUsedSize = helpers_segment.readUsedSize;
exports.renderText = helpers_segment.renderText;
exports.requestAnimFrame = helpers_segment.requestAnimFrame;
exports.resolve = helpers_segment.resolve;
exports.resolveObjectKey = helpers_segment.resolveObjectKey;
exports.restoreTextDirection = helpers_segment.restoreTextDirection;
exports.retinaScale = helpers_segment.retinaScale;
exports.setsEqual = helpers_segment.setsEqual;
exports.sign = helpers_segment.sign;
exports.splineCurve = helpers_segment.splineCurve;
exports.splineCurveMonotone = helpers_segment.splineCurveMonotone;
exports.supportsEventListenerOptions = helpers_segment.supportsEventListenerOptions;
exports.throttled = helpers_segment.throttled;
exports.toDegrees = helpers_segment.toDegrees;
exports.toDimension = helpers_segment.toDimension;
exports.toFont = helpers_segment.toFont;
exports.toFontString = helpers_segment.toFontString;
exports.toLineHeight = helpers_segment.toLineHeight;
exports.toPadding = helpers_segment.toPadding;
exports.toPercentage = helpers_segment.toPercentage;
exports.toRadians = helpers_segment.toRadians;
exports.toTRBL = helpers_segment.toTRBL;
exports.toTRBLCorners = helpers_segment.toTRBLCorners;
exports.uid = helpers_segment.uid;
exports.unclipArea = helpers_segment.unclipArea;
exports.unlistenArrayEvents = helpers_segment.unlistenArrayEvents;
exports.valueOrDefault = helpers_segment.valueOrDefault;
//# sourceMappingURL=helpers.cjs.map

View file

@ -0,0 +1 @@
{"version":3,"file":"helpers.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}

View file

@ -0,0 +1,9 @@
/*!
* Chart.js v4.1.2
* https://www.chartjs.org
* (c) 2023 Chart.js Contributors
* Released under the MIT License
*/
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';
import '@kurkle/color';
//# sourceMappingURL=helpers.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"helpers.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}

View file

@ -0,0 +1,85 @@
/**
* Note: typedefs are auto-exported, so use a made-up `canvas` namespace where
* necessary to avoid duplicates with `export * from './helpers`; see
* https://github.com/microsoft/TypeScript/issues/46011
* @typedef { import('../core/core.controller.js').default } canvas.Chart
* @typedef { import('../types/index.js').Point } Point
*/
/**
* @namespace Chart.helpers.canvas
*/
/**
* Converts the given font object into a CSS font string.
* @param {object} font - A font object.
* @return {string|null} The CSS font string. See https://developer.mozilla.org/en-US/docs/Web/CSS/font
* @private
*/
export function toFontString(font: object): string | null;
/**
* @private
*/
export function _measureText(ctx: any, data: any, gc: any, longest: any, string: any): any;
/**
* @private
*/
export function _longestText(ctx: any, font: any, arrayOfThings: any, cache: any): number;
/**
* Returns the aligned pixel value to avoid anti-aliasing blur
* @param {canvas.Chart} chart - The chart instance.
* @param {number} pixel - A pixel value.
* @param {number} width - The width of the element.
* @returns {number} The aligned pixel value.
* @private
*/
export function _alignPixel(chart: canvas.Chart, pixel: number, width: number): number;
/**
* Clears the entire canvas.
* @param {HTMLCanvasElement} canvas
* @param {CanvasRenderingContext2D} [ctx]
*/
export function clearCanvas(canvas: HTMLCanvasElement, ctx?: CanvasRenderingContext2D): void;
export function drawPoint(ctx: any, options: any, x: any, y: any): void;
export function drawPointLegend(ctx: any, options: any, x: any, y: any, w: any): void;
/**
* Returns true if the point is inside the rectangle
* @param {Point} point - The point to test
* @param {object} area - The rectangle
* @param {number} [margin] - allowed margin
* @returns {boolean}
* @private
*/
export function _isPointInArea(point: Point, area: object, margin?: number): boolean;
export function clipArea(ctx: any, area: any): void;
export function unclipArea(ctx: any): void;
/**
* @private
*/
export function _steppedLineTo(ctx: any, previous: any, target: any, flip: any, mode: any): any;
/**
* @private
*/
export function _bezierCurveTo(ctx: any, previous: any, target: any, flip: any): any;
/**
* Render text onto the canvas
*/
export function renderText(ctx: any, text: any, x: any, y: any, font: any, opts?: {}): void;
/**
* Add a path of a rectangle with rounded corners to the current sub-path
* @param {CanvasRenderingContext2D} ctx Context
* @param {*} rect Bounding rect
*/
export function addRoundedRectPath(ctx: CanvasRenderingContext2D, rect: any): void;
export namespace canvas {
/**
* Note: typedefs are auto-exported, so use a made-up `canvas` namespace where
* necessary to avoid duplicates with `export * from './helpers`; see
* https://github.com/microsoft/TypeScript/issues/46011
*/
type Chart = import('../core/core.controller.js').default;
}
/**
* Note: typedefs are auto-exported, so use a made-up `canvas` namespace where
* necessary to avoid duplicates with `export * from './helpers`; see
* https://github.com/microsoft/TypeScript/issues/46011
*/
export type Point = import('../types/index.js').Point;

View file

@ -0,0 +1,68 @@
/**
* Binary search
* @param table - the table search. must be sorted!
* @param value - value to find
* @param cmp
* @private
*/
export declare function _lookup(table: number[], value: number, cmp?: (value: number) => boolean): {
lo: number;
hi: number;
};
export declare function _lookup<T>(table: T[], value: number, cmp: (value: number) => boolean): {
lo: number;
hi: number;
};
/**
* Binary search
* @param table - the table search. must be sorted!
* @param key - property name for the value in each entry
* @param value - value to find
* @param last - lookup last index
* @private
*/
export declare const _lookupByKey: (table: Record<string, number>[], key: string, value: number, last?: boolean) => {
lo: number;
hi: number;
};
/**
* Reverse binary search
* @param table - the table search. must be sorted!
* @param key - property name for the value in each entry
* @param value - value to find
* @private
*/
export declare const _rlookupByKey: (table: Record<string, number>[], key: string, value: number) => {
lo: number;
hi: number;
};
/**
* Return subset of `values` between `min` and `max` inclusive.
* Values are assumed to be in sorted order.
* @param values - sorted array of values
* @param min - min value
* @param max - max value
*/
export declare function _filterBetween(values: number[], min: number, max: number): number[];
export interface ArrayListener<T> {
_onDataPush?(...item: T[]): void;
_onDataPop?(): void;
_onDataShift?(): void;
_onDataSplice?(index: number, deleteCount: number, ...items: T[]): void;
_onDataUnshift?(...item: T[]): void;
}
/**
* Hooks the array methods that add or remove values ('push', pop', 'shift', 'splice',
* 'unshift') and notify the listener AFTER the array has been altered. Listeners are
* called on the '_onData*' callbacks (e.g. _onDataPush, etc.) with same arguments.
*/
export declare function listenArrayEvents<T>(array: T[], listener: ArrayListener<T>): void;
/**
* Removes the given array event listener and cleanup extra attached properties (such as
* the _chartjs stub and overridden methods) if array doesn't have any more listeners.
*/
export declare function unlistenArrayEvents<T>(array: T[], listener: ArrayListener<T>): void;
/**
* @param items
*/
export declare function _arrayUnique<T>(items: T[]): T[];

View file

@ -0,0 +1,13 @@
import { Color } from '@kurkle/color';
export declare function isPatternOrGradient(value: unknown): value is CanvasPattern | CanvasGradient;
export declare function color(value: CanvasGradient): CanvasGradient;
export declare function color(value: CanvasPattern): CanvasPattern;
export declare function color(value: string | {
r: number;
g: number;
b: number;
a: number;
} | [number, number, number] | [number, number, number, number]): Color;
export declare function getHoverColor(value: CanvasGradient): CanvasGradient;
export declare function getHoverColor(value: CanvasPattern): CanvasPattern;
export declare function getHoverColor(value: string): string;

View file

@ -0,0 +1,61 @@
/**
* Creates a Proxy for resolving raw values for options.
* @param {object[]} scopes - The option scopes to look for values, in resolution order
* @param {string[]} [prefixes] - The prefixes for values, in resolution order.
* @param {object[]} [rootScopes] - The root option scopes
* @param {string|boolean} [fallback] - Parent scopes fallback
* @param {function} [getTarget] - callback for getting the target for changed values
* @returns Proxy
* @private
*/
export function _createResolver(scopes: object[], prefixes?: string[], rootScopes?: object[], fallback?: string | boolean, getTarget?: Function): {
[Symbol.toStringTag]: string;
_cacheable: boolean;
_scopes: any[];
_rootScopes: any[];
_fallback: string | boolean;
_getTarget: Function;
override: (scope: any) => any;
};
/**
* Returns an Proxy for resolving option values with context.
* @param {object} proxy - The Proxy returned by `_createResolver`
* @param {object} context - Context object for scriptable/indexable options
* @param {object} [subProxy] - The proxy provided for scriptable options
* @param {{scriptable: boolean, indexable: boolean, allKeys?: boolean}} [descriptorDefaults] - Defaults for descriptors
* @private
*/
export function _attachContext(proxy: object, context: object, subProxy?: object, descriptorDefaults?: {
scriptable: boolean;
indexable: boolean;
allKeys?: boolean;
}): {
_cacheable: boolean;
_proxy: any;
_context: any;
_subProxy: any;
_stack: Set<any>;
_descriptors: {
allKeys: any;
scriptable: any;
indexable: any;
isScriptable: (...args: any[]) => any;
isIndexable: (...args: any[]) => any;
};
setContext: (ctx: any) => any;
override: (scope: any) => any;
};
/**
* @private
*/
export function _descriptors(proxy: any, defaults?: {
scriptable: boolean;
indexable: boolean;
}): {
allKeys: any;
scriptable: any;
indexable: any;
isScriptable: (...args: any[]) => any;
isIndexable: (...args: any[]) => any;
};
export function _parseObjectDataRadialScale(meta: any, data: any, start: any, count: any): any[];

View file

@ -0,0 +1,147 @@
/**
* @namespace Chart.helpers
*/
import type { AnyObject } from '../types/basic.js';
import type { ActiveDataPoint, ChartEvent } from '../types/index.js';
/**
* An empty function that can be used, for example, for optional callback.
*/
export declare function noop(): void;
/**
* Returns a unique id, sequentially generated from a global variable.
*/
export declare const uid: () => number;
/**
* Returns true if `value` is neither null nor undefined, else returns false.
* @param value - The value to test.
* @since 2.7.0
*/
export declare function isNullOrUndef(value: unknown): value is null | undefined;
/**
* Returns true if `value` is an array (including typed arrays), else returns false.
* @param value - The value to test.
* @function
*/
export declare function isArray<T = unknown>(value: unknown): value is T[];
/**
* Returns true if `value` is an object (excluding null), else returns false.
* @param value - The value to test.
* @since 2.7.0
*/
export declare function isObject(value: unknown): value is AnyObject;
/**
* Returns true if `value` is a finite number, else returns false
* @param value - The value to test.
*/
declare function isNumberFinite(value: unknown): value is number;
export { isNumberFinite as isFinite, };
/**
* Returns `value` if finite, else returns `defaultValue`.
* @param value - The value to return if defined.
* @param defaultValue - The value to return if `value` is not finite.
*/
export declare function finiteOrDefault(value: unknown, defaultValue: number): number;
/**
* Returns `value` if defined, else returns `defaultValue`.
* @param value - The value to return if defined.
* @param defaultValue - The value to return if `value` is undefined.
*/
export declare function valueOrDefault<T>(value: T | undefined, defaultValue: T): T;
export declare const toPercentage: (value: number | string, dimension: number) => number;
export declare const toDimension: (value: number | string, dimension: number) => number;
/**
* Calls `fn` with the given `args` in the scope defined by `thisArg` and returns the
* value returned by `fn`. If `fn` is not a function, this method returns undefined.
* @param fn - The function to call.
* @param args - The arguments with which `fn` should be called.
* @param [thisArg] - The value of `this` provided for the call to `fn`.
*/
export declare function callback<T extends (this: TA, ...restArgs: unknown[]) => R, TA, R>(fn: T | undefined, args: unknown[], thisArg?: TA): R | undefined;
/**
* Note(SB) for performance sake, this method should only be used when loopable type
* is unknown or in none intensive code (not called often and small loopable). Else
* it's preferable to use a regular for() loop and save extra function calls.
* @param loopable - The object or array to be iterated.
* @param fn - The function to call for each item.
* @param [thisArg] - The value of `this` provided for the call to `fn`.
* @param [reverse] - If true, iterates backward on the loopable.
*/
export declare function each<T, TA>(loopable: Record<string, T>, fn: (this: TA, v: T, i: string) => void, thisArg?: TA, reverse?: boolean): void;
export declare function each<T, TA>(loopable: T[], fn: (this: TA, v: T, i: number) => void, thisArg?: TA, reverse?: boolean): void;
/**
* Returns true if the `a0` and `a1` arrays have the same content, else returns false.
* @param a0 - The array to compare
* @param a1 - The array to compare
* @private
*/
export declare function _elementsEqual(a0: ActiveDataPoint[], a1: ActiveDataPoint[]): boolean;
/**
* Returns a deep copy of `source` without keeping references on objects and arrays.
* @param source - The value to clone.
*/
export declare function clone<T>(source: T): T;
/**
* The default merger when Chart.helpers.merge is called without merger option.
* Note(SB): also used by mergeConfig and mergeScaleConfig as fallback.
* @private
*/
export declare function _merger(key: string, target: AnyObject, source: AnyObject, options: AnyObject): void;
export interface MergeOptions {
merger?: (key: string, target: AnyObject, source: AnyObject, options?: AnyObject) => void;
}
/**
* Recursively deep copies `source` properties into `target` with the given `options`.
* IMPORTANT: `target` is not cloned and will be updated with `source` properties.
* @param target - The target object in which all sources are merged into.
* @param source - Object(s) to merge into `target`.
* @param [options] - Merging options:
* @param [options.merger] - The merge method (key, target, source, options)
* @returns The `target` object.
*/
export declare function merge<T>(target: T, source: [], options?: MergeOptions): T;
export declare function merge<T, S1>(target: T, source: S1, options?: MergeOptions): T & S1;
export declare function merge<T, S1>(target: T, source: [S1], options?: MergeOptions): T & S1;
export declare function merge<T, S1, S2>(target: T, source: [S1, S2], options?: MergeOptions): T & S1 & S2;
export declare function merge<T, S1, S2, S3>(target: T, source: [S1, S2, S3], options?: MergeOptions): T & S1 & S2 & S3;
export declare function merge<T, S1, S2, S3, S4>(target: T, source: [S1, S2, S3, S4], options?: MergeOptions): T & S1 & S2 & S3 & S4;
export declare function merge<T>(target: T, source: AnyObject[], options?: MergeOptions): AnyObject;
/**
* Recursively deep copies `source` properties into `target` *only* if not defined in target.
* IMPORTANT: `target` is not cloned and will be updated with `source` properties.
* @param target - The target object in which all sources are merged into.
* @param source - Object(s) to merge into `target`.
* @returns The `target` object.
*/
export declare function mergeIf<T>(target: T, source: []): T;
export declare function mergeIf<T, S1>(target: T, source: S1): T & S1;
export declare function mergeIf<T, S1>(target: T, source: [S1]): T & S1;
export declare function mergeIf<T, S1, S2>(target: T, source: [S1, S2]): T & S1 & S2;
export declare function mergeIf<T, S1, S2, S3>(target: T, source: [S1, S2, S3]): T & S1 & S2 & S3;
export declare function mergeIf<T, S1, S2, S3, S4>(target: T, source: [S1, S2, S3, S4]): T & S1 & S2 & S3 & S4;
export declare function mergeIf<T>(target: T, source: AnyObject[]): AnyObject;
/**
* Merges source[key] in target[key] only if target[key] is undefined.
* @private
*/
export declare function _mergerIf(key: string, target: AnyObject, source: AnyObject): void;
/**
* @private
*/
export declare function _deprecated(scope: string, value: unknown, previous: string, current: string): void;
/**
* @private
*/
export declare function _splitKey(key: string): string[];
export declare function resolveObjectKey(obj: AnyObject, key: string): AnyObject;
/**
* @private
*/
export declare function _capitalize(str: string): string;
export declare const defined: (value: unknown) => boolean;
export declare const isFunction: (value: unknown) => value is (...args: any[]) => any;
export declare const setsEqual: <T>(a: Set<T>, b: Set<T>) => boolean;
/**
* @param e - The event
* @private
*/
export declare function _isClickEvent(e: ChartEvent): boolean;

View file

@ -0,0 +1,25 @@
import type { ChartArea } from '../types/index.js';
export interface SplinePoint {
x: number;
y: number;
skip?: boolean;
cp1x?: number;
cp1y?: number;
cp2x?: number;
cp2y?: number;
}
export declare function splineCurve(firstPoint: SplinePoint, middlePoint: SplinePoint, afterPoint: SplinePoint, t: number): {
previous: SplinePoint;
next: SplinePoint;
};
/**
* This function calculates Bézier control points in a similar way than |splineCurve|,
* but preserves monotonicity of the provided data and ensures no local extremums are added
* between the dataset discrete points due to the interpolation.
* See : https://en.wikipedia.org/wiki/Monotone_cubic_interpolation
*/
export declare function splineCurveMonotone(points: SplinePoint[], indexAxis?: 'x' | 'y'): void;
/**
* @private
*/
export declare function _updateBezierControlPoints(points: SplinePoint[], options: any, area: ChartArea, loop: boolean, indexAxis: 'x' | 'y'): void;

View file

@ -0,0 +1,55 @@
import type Chart from '../core/core.controller.js';
import type { ChartEvent } from '../types.js';
/**
* Note: typedefs are auto-exported, so use a made-up `dom` namespace where
* necessary to avoid duplicates with `export * from './helpers`; see
* https://github.com/microsoft/TypeScript/issues/46011
* @typedef { import('../core/core.controller.js').default } dom.Chart
* @typedef { import('../../types').ChartEvent } ChartEvent
*/
/**
* @private
*/
export declare function _isDomSupported(): boolean;
/**
* @private
*/
export declare function _getParentNode(domNode: HTMLCanvasElement): HTMLCanvasElement;
export declare function getStyle(el: HTMLElement, property: string): string;
/**
* Gets an event's x, y coordinates, relative to the chart area
* @param event
* @param chart
* @returns x and y coordinates of the event
*/
export declare function getRelativePosition(event: Event | ChartEvent | TouchEvent | MouseEvent, chart: Chart): {
x: number;
y: number;
};
export declare function getMaximumSize(canvas: HTMLCanvasElement, bbWidth?: number, bbHeight?: number, aspectRatio?: number): {
width: number;
height: number;
};
/**
* @param chart
* @param forceRatio
* @param forceStyle
* @returns True if the canvas context size or transformation has changed.
*/
export declare function retinaScale(chart: Chart, forceRatio: number, forceStyle?: boolean): boolean | void;
/**
* Detects support for options object argument in addEventListener.
* https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#Safely_detecting_option_support
* @private
*/
export declare const supportsEventListenerOptions: boolean;
/**
* The "used" size is the final value of a dimension property after all calculations have
* been performed. This method uses the computed style of `element` but returns undefined
* if the computed style is not expressed in pixels. That can happen in some cases where
* `element` has a size relative to its parent and this last one is not yet displayed,
* for example because of `display: none` on a parent node.
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/used_value
* @returns Size in pixels or undefined if unknown.
*/
export declare function readUsedSize(element: HTMLElement, property: 'width' | 'height'): number | undefined;

View file

@ -0,0 +1,40 @@
/**
* Easing functions adapted from Robert Penner's easing equations.
* @namespace Chart.helpers.easing.effects
* @see http://www.robertpenner.com/easing/
*/
declare const effects: {
readonly linear: (t: number) => number;
readonly easeInQuad: (t: number) => number;
readonly easeOutQuad: (t: number) => number;
readonly easeInOutQuad: (t: number) => number;
readonly easeInCubic: (t: number) => number;
readonly easeOutCubic: (t: number) => number;
readonly easeInOutCubic: (t: number) => number;
readonly easeInQuart: (t: number) => number;
readonly easeOutQuart: (t: number) => number;
readonly easeInOutQuart: (t: number) => number;
readonly easeInQuint: (t: number) => number;
readonly easeOutQuint: (t: number) => number;
readonly easeInOutQuint: (t: number) => number;
readonly easeInSine: (t: number) => number;
readonly easeOutSine: (t: number) => number;
readonly easeInOutSine: (t: number) => number;
readonly easeInExpo: (t: number) => number;
readonly easeOutExpo: (t: number) => number;
readonly easeInOutExpo: (t: number) => number;
readonly easeInCirc: (t: number) => number;
readonly easeOutCirc: (t: number) => number;
readonly easeInOutCirc: (t: number) => number;
readonly easeInElastic: (t: number) => number;
readonly easeOutElastic: (t: number) => number;
readonly easeInOutElastic: (t: number) => number;
readonly easeInBack: (t: number) => number;
readonly easeOutBack: (t: number) => number;
readonly easeInOutBack: (t: number) => number;
readonly easeInBounce: (t: number) => number;
readonly easeOutBounce: (t: number) => number;
readonly easeInOutBounce: (t: number) => number;
};
export declare type EasingFunction = keyof typeof effects;
export default effects;

View file

@ -0,0 +1,45 @@
import type { ChartMeta, PointElement } from '../types/index.js';
export declare function fontString(pixelSize: number, fontStyle: string, fontFamily: string): string;
/**
* Request animation polyfill
*/
export declare const requestAnimFrame: (((callback: FrameRequestCallback) => number) & typeof requestAnimationFrame) | ((callback: any) => any);
/**
* Throttles calling `fn` once per animation frame
* Latest arguments are used on the actual call
*/
export declare function throttled<TArgs extends Array<any>>(fn: (...args: TArgs) => void, thisArg: any): (...args: TArgs) => void;
/**
* Debounces calling `fn` for `delay` ms
*/
export declare function debounce<TArgs extends Array<any>>(fn: (...args: TArgs) => void, delay: number): (...args: TArgs) => number;
/**
* Converts 'start' to 'left', 'end' to 'right' and others to 'center'
* @private
*/
export declare const _toLeftRightCenter: (align: 'start' | 'end' | 'center') => "center" | "left" | "right";
/**
* Returns `start`, `end` or `(start + end) / 2` depending on `align`. Defaults to `center`
* @private
*/
export declare const _alignStartEnd: (align: 'start' | 'end' | 'center', start: number, end: number) => number;
/**
* Returns `left`, `right` or `(left + right) / 2` depending on `align`. Defaults to `left`
* @private
*/
export declare const _textX: (align: 'left' | 'right' | 'center', left: number, right: number, rtl: boolean) => number;
/**
* Return start and count of visible points.
* @private
*/
export declare function _getStartAndCountOfVisiblePoints(meta: ChartMeta<'line' | 'scatter'>, points: PointElement[], animationsDisabled: boolean): {
start: number;
count: number;
};
/**
* Checks if the scale ranges have changed.
* @param {object} meta - dataset meta.
* @returns {boolean}
* @private
*/
export declare function _scaleRangesChanged(meta: any): boolean;

View file

@ -0,0 +1,23 @@
import type { Point } from '../types/geometric.js';
import type { SplinePoint } from './helpers.curve.js';
/**
* @private
*/
export declare function _pointInLine(p1: Point, p2: Point, t: number, mode?: any): {
x: number;
y: number;
};
/**
* @private
*/
export declare function _steppedInterpolation(p1: Point, p2: Point, t: number, mode: 'middle' | 'after' | unknown): {
x: number;
y: number;
};
/**
* @private
*/
export declare function _bezierInterpolation(p1: SplinePoint, p2: SplinePoint, t: number, mode?: any): {
x: number;
y: number;
};

View file

@ -0,0 +1 @@
export declare function formatNumber(num: number, locale: string, options?: Intl.NumberFormatOptions): string;

View file

@ -0,0 +1,84 @@
import type { Point } from '../types/geometric.js';
/**
* @alias Chart.helpers.math
* @namespace
*/
export declare const PI: number;
export declare const TAU: number;
export declare const PITAU: number;
export declare const INFINITY: number;
export declare const RAD_PER_DEG: number;
export declare const HALF_PI: number;
export declare const QUARTER_PI: number;
export declare const TWO_THIRDS_PI: number;
export declare const log10: (x: number) => number;
export declare const sign: (x: number) => number;
export declare function almostEquals(x: number, y: number, epsilon: number): boolean;
/**
* Implementation of the nice number algorithm used in determining where axis labels will go
*/
export declare function niceNum(range: number): number;
/**
* Returns an array of factors sorted from 1 to sqrt(value)
* @private
*/
export declare function _factorize(value: number): number[];
export declare function isNumber(n: unknown): n is number;
export declare function almostWhole(x: number, epsilon: number): boolean;
/**
* @private
*/
export declare function _setMinAndMaxByKey(array: Record<string, number>[], target: {
min: number;
max: number;
}, property: string): void;
export declare function toRadians(degrees: number): number;
export declare function toDegrees(radians: number): number;
/**
* Returns the number of decimal places
* i.e. the number of digits after the decimal point, of the value of this Number.
* @param x - A number.
* @returns The number of decimal places.
* @private
*/
export declare function _decimalPlaces(x: number): number;
export declare function getAngleFromPoint(centrePoint: Point, anglePoint: Point): {
angle: number;
distance: number;
};
export declare function distanceBetweenPoints(pt1: Point, pt2: Point): number;
/**
* Shortest distance between angles, in either direction.
* @private
*/
export declare function _angleDiff(a: number, b: number): number;
/**
* Normalize angle to be between 0 and 2*PI
* @private
*/
export declare function _normalizeAngle(a: number): number;
/**
* @private
*/
export declare function _angleBetween(angle: number, start: number, end: number, sameAngleIsFullCircle?: boolean): boolean;
/**
* Limit `value` between `min` and `max`
* @param value
* @param min
* @param max
* @private
*/
export declare function _limitValue(value: number, min: number, max: number): number;
/**
* @param {number} value
* @private
*/
export declare function _int16Range(value: number): number;
/**
* @param value
* @param start
* @param end
* @param [epsilon]
* @private
*/
export declare function _isBetween(value: number, start: number, end: number, epsilon?: number): boolean;

View file

@ -0,0 +1,101 @@
import { Point } from './helpers.canvas.js';
import type { ChartArea, FontSpec } from '../types/index.js';
import type { TRBL, TRBLCorners } from '../types/geometric.js';
/**
* @alias Chart.helpers.options
* @namespace
*/
/**
* Converts the given line height `value` in pixels for a specific font `size`.
* @param value - The lineHeight to parse (eg. 1.6, '14px', '75%', '1.6em').
* @param size - The font size (in pixels) used to resolve relative `value`.
* @returns The effective line height in pixels (size * 1.2 if value is invalid).
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/line-height
* @since 2.7.0
*/
export declare function toLineHeight(value: number | string, size: number): number;
/**
* @param value
* @param props
*/
export declare function _readValueToProps<K extends string>(value: number | Record<K, number>, props: K[]): Record<K, number>;
export declare function _readValueToProps<K extends string, T extends string>(value: number | Record<K & T, number>, props: Record<T, K>): Record<T, number>;
/**
* Converts the given value into a TRBL object.
* @param value - If a number, set the value to all TRBL component,
* else, if an object, use defined properties and sets undefined ones to 0.
* x / y are shorthands for same value for left/right and top/bottom.
* @returns The padding values (top, right, bottom, left)
* @since 3.0.0
*/
export declare function toTRBL(value: number | TRBL | Point): Record<"left" | "top" | "bottom" | "right", number>;
/**
* Converts the given value into a TRBL corners object (similar with css border-radius).
* @param value - If a number, set the value to all TRBL corner components,
* else, if an object, use defined properties and sets undefined ones to 0.
* @returns The TRBL corner values (topLeft, topRight, bottomLeft, bottomRight)
* @since 3.0.0
*/
export declare function toTRBLCorners(value: number | TRBLCorners): Record<"topLeft" | "topRight" | "bottomLeft" | "bottomRight", number>;
/**
* Converts the given value into a padding object with pre-computed width/height.
* @param value - If a number, set the value to all TRBL component,
* else, if an object, use defined properties and sets undefined ones to 0.
* x / y are shorthands for same value for left/right and top/bottom.
* @returns The padding values (top, right, bottom, left, width, height)
* @since 2.7.0
*/
export declare function toPadding(value?: number | TRBL): ChartArea;
export interface CanvasFontSpec extends FontSpec {
string: string;
}
/**
* Parses font options and returns the font object.
* @param options - A object that contains font options to be parsed.
* @param fallback - A object that contains fallback font options.
* @return The font object.
* @private
*/
export declare function toFont(options: Partial<FontSpec>, fallback?: Partial<FontSpec>): {
family: string;
lineHeight: number;
size: number;
style: "normal" | "inherit" | "italic" | "oblique" | "initial";
weight: string;
string: string;
};
/**
* Evaluates the given `inputs` sequentially and returns the first defined value.
* @param inputs - An array of values, falling back to the last value.
* @param context - If defined and the current value is a function, the value
* is called with `context` as first argument and the result becomes the new input.
* @param index - If defined and the current value is an array, the value
* at `index` become the new input.
* @param info - object to return information about resolution in
* @param info.cacheable - Will be set to `false` if option is not cacheable.
* @since 2.7.0
*/
export declare function resolve(inputs: Array<unknown>, context?: object, index?: number, info?: {
cacheable: boolean;
}): unknown;
/**
* @param minmax
* @param grace
* @param beginAtZero
* @private
*/
export declare function _addGrace(minmax: {
min: number;
max: number;
}, grace: number | string, beginAtZero: boolean): {
min: number;
max: number;
};
/**
* Create a context inheriting parentContext
* @param parentContext
* @param context
* @returns
*/
export declare function createContext<T extends object>(parentContext: null, context: T): T;
export declare function createContext<T extends object, P extends T>(parentContext: P, context: T): P & T;

View file

@ -0,0 +1,10 @@
export interface RTLAdapter {
x(x: number): number;
setWidth(w: number): void;
textAlign(align: 'center' | 'left' | 'right'): 'center' | 'left' | 'right';
xPlus(x: number, value: number): number;
leftForLtr(x: number, itemWidth: number): number;
}
export declare function getRtlAdapter(rtl: boolean, rectX: number, width: number): RTLAdapter;
export declare function overrideTextDirection(ctx: CanvasRenderingContext2D, direction: 'ltr' | 'rtl'): void;
export declare function restoreTextDirection(ctx: CanvasRenderingContext2D, original?: [string, string]): void;

View file

@ -0,0 +1,65 @@
/**
* Returns the sub-segment(s) of a line segment that fall in the given bounds
* @param {object} segment
* @param {number} segment.start - start index of the segment, referring the points array
* @param {number} segment.end - end index of the segment, referring the points array
* @param {boolean} segment.loop - indicates that the segment is a loop
* @param {object} [segment.style] - segment style
* @param {PointElement[]} points - the points that this segment refers to
* @param {object} [bounds]
* @param {string} bounds.property - the property of a `PointElement` we are bounding. `x`, `y` or `angle`.
* @param {number} bounds.start - start value of the property
* @param {number} bounds.end - end value of the property
* @private
**/
export function _boundSegment(segment: {
start: number;
end: number;
loop: boolean;
style?: object;
}, points: PointElement[], bounds?: {
property: string;
start: number;
end: number;
}): {
start: number;
end: number;
loop: boolean;
style?: object;
}[];
/**
* Returns the segments of the line that are inside given bounds
* @param {LineElement} line
* @param {object} [bounds]
* @param {string} bounds.property - the property we are bounding with. `x`, `y` or `angle`.
* @param {number} bounds.start - start value of the `property`
* @param {number} bounds.end - end value of the `property`
* @private
*/
export function _boundSegments(line: LineElement, bounds?: {
property: string;
start: number;
end: number;
}): {
start: number;
end: number;
loop: boolean;
style?: object;
}[];
/**
* Compute the continuous segments that define the whole line
* There can be skipped points within a segment, if spanGaps is true.
* @param {LineElement} line
* @param {object} [segmentOptions]
* @return {Segment[]}
* @private
*/
export function _computeSegments(line: LineElement, segmentOptions?: object): Segment[];
export type LineElement = import('../elements/element.line.js').default;
export type PointElement = import('../elements/element.point.js').default;
export type Segment = {
start: number;
end: number;
loop: boolean;
style?: any;
};

View file

@ -0,0 +1,15 @@
export * from './helpers.color.js';
export * from './helpers.core.js';
export * from './helpers.canvas.js';
export * from './helpers.collection.js';
export * from './helpers.config.js';
export * from './helpers.curve.js';
export * from './helpers.dom.js';
export { default as easingEffects } from './helpers.easing.js';
export * from './helpers.extras.js';
export * from './helpers.interpolation.js';
export * from './helpers.intl.js';
export * from './helpers.options.js';
export * from './helpers.math.js';
export * from './helpers.rtl.js';
export * from './helpers.segment.js';

View file

@ -0,0 +1,17 @@
/**
* Temporary entry point of the types at the time of the transition.
* After transition done need to remove it in favor of index.ts
*/
export * from './helpers.color.js';
export * from './helpers.collection.js';
export * from './helpers.core.js';
export * from './helpers.curve.js';
export * from './helpers.dom.js';
export * from './helpers.easing.js';
export * from './helpers.extras.js';
export * from './helpers.interpolation.js';
export * from './helpers.intl.js';
export * from './helpers.math.js';
export * from './helpers.options.js';
export * from './helpers.rtl.js';
export * from '../types/helpers/index.js';

View file

@ -0,0 +1,12 @@
export * from './controllers/index.js';
export * from './core/index.js';
export * from './elements/index.js';
export * from './platform/index.js';
export * from './plugins/index.js';
export * from './scales/index.js';
import * as controllers from './controllers/index.js';
import * as elements from './elements/index.js';
import * as plugins from './plugins/index.js';
import * as scales from './scales/index.js';
export { controllers, elements, plugins, scales, };
export declare const registerables: (typeof controllers | typeof elements | typeof plugins | typeof scales)[];

View file

@ -0,0 +1,5 @@
/**
* @namespace Chart
*/
import Chart from './core/core.controller.js';
export default Chart;

View file

@ -0,0 +1,5 @@
export function _detectPlatform(canvas: any): typeof BasicPlatform | typeof DomPlatform;
import BasicPlatform from "./platform.basic.js";
import DomPlatform from "./platform.dom.js";
import BasePlatform from "./platform.base.js";
export { BasePlatform, BasicPlatform, DomPlatform };

View file

@ -0,0 +1,63 @@
/**
* @typedef { import('../core/core.controller.js').default } Chart
*/
/**
* Abstract class that allows abstracting platform dependencies away from the chart.
*/
export default class BasePlatform {
/**
* Called at chart construction time, returns a context2d instance implementing
* the [W3C Canvas 2D Context API standard]{@link https://www.w3.org/TR/2dcontext/}.
* @param {HTMLCanvasElement} canvas - The canvas from which to acquire context (platform specific)
* @param {number} [aspectRatio] - The chart options
*/
acquireContext(canvas: HTMLCanvasElement, aspectRatio?: number): void;
/**
* Called at chart destruction time, releases any resources associated to the context
* previously returned by the acquireContext() method.
* @param {CanvasRenderingContext2D} context - The context2d instance
* @returns {boolean} true if the method succeeded, else false
*/
releaseContext(context: CanvasRenderingContext2D): boolean;
/**
* Registers the specified listener on the given chart.
* @param {Chart} chart - Chart from which to listen for event
* @param {string} type - The ({@link ChartEvent}) type to listen for
* @param {function} listener - Receives a notification (an object that implements
* the {@link ChartEvent} interface) when an event of the specified type occurs.
*/
addEventListener(chart: Chart, type: string, listener: Function): void;
/**
* Removes the specified listener previously registered with addEventListener.
* @param {Chart} chart - Chart from which to remove the listener
* @param {string} type - The ({@link ChartEvent}) type to remove
* @param {function} listener - The listener function to remove from the event target.
*/
removeEventListener(chart: Chart, type: string, listener: Function): void;
/**
* @returns {number} the current devicePixelRatio of the device this platform is connected to.
*/
getDevicePixelRatio(): number;
/**
* Returns the maximum size in pixels of given canvas element.
* @param {HTMLCanvasElement} element
* @param {number} [width] - content width of parent element
* @param {number} [height] - content height of parent element
* @param {number} [aspectRatio] - aspect ratio to maintain
*/
getMaximumSize(element: HTMLCanvasElement, width?: number, height?: number, aspectRatio?: number): {
width: number;
height: number;
};
/**
* @param {HTMLCanvasElement} canvas
* @returns {boolean} true if the canvas is attached to the platform, false if not.
*/
isAttached(canvas: HTMLCanvasElement): boolean;
/**
* Updates config with platform specific requirements
* @param {import('../core/core.config.js').default} config
*/
updateConfig(config: import('../core/core.config.js').default): void;
}
export type Chart = import('../core/core.controller.js').default;

View file

@ -0,0 +1,10 @@
/**
* Platform class for charts without access to the DOM or to many element properties
* This platform is used by default for any chart passed an OffscreenCanvas.
* @extends BasePlatform
*/
export default class BasicPlatform extends BasePlatform {
acquireContext(item: any): any;
updateConfig(config: any): void;
}
import BasePlatform from "./platform.base.js";

View file

@ -0,0 +1,19 @@
/**
* Platform class for charts that can access the DOM and global window/document properties
* @extends BasePlatform
*/
export default class DomPlatform extends BasePlatform {
/**
* @param {HTMLCanvasElement} canvas
* @param {number} [aspectRatio]
* @return {CanvasRenderingContext2D|null}
*/
acquireContext(canvas: HTMLCanvasElement, aspectRatio?: number): CanvasRenderingContext2D | null;
/**
* @param {Chart} chart
* @param {string} type
*/
removeEventListener(chart: Chart, type: string): void;
}
export type Chart = import('../core/core.controller.js').default;
import BasePlatform from "./platform.base.js";

View file

@ -0,0 +1,7 @@
export { default as Colors } from "./plugin.colors.js";
export { default as Decimation } from "./plugin.decimation.js";
export { default as Filler } from "./plugin.filler/index.js";
export { default as Legend } from "./plugin.legend.js";
export { default as SubTitle } from "./plugin.subtitle.js";
export { default as Title } from "./plugin.title.js";
export { default as Tooltip } from "./plugin.tooltip.js";

View file

@ -0,0 +1,11 @@
import type { Chart } from '../types.js';
export interface ColorsPluginOptions {
enabled?: boolean;
forceOverride?: boolean;
}
declare const _default: {
id: string;
defaults: ColorsPluginOptions;
beforeLayout(chart: Chart, _args: any, options: ColorsPluginOptions): void;
};
export default _default;

View file

@ -0,0 +1,11 @@
declare namespace _default {
const id: string;
namespace defaults {
const algorithm: string;
const enabled: boolean;
}
function beforeElementsUpdate(chart: any, args: any, options: any): void;
function destroy(chart: any): void;
function destroy(chart: any): void;
}
export default _default;

View file

@ -0,0 +1 @@
export function _drawfill(ctx: any, source: any, area: any): void;

View file

@ -0,0 +1,14 @@
/**
* @param {PointElement[] | { x: number; y: number; }} boundary
* @param {LineElement} line
* @return {LineElement?}
*/
export function _createBoundaryLine(boundary: PointElement[] | {
x: number;
y: number;
}, line: LineElement): LineElement | null;
export function _shouldApplyFill(source: any): boolean;
export type Chart = import('../../core/core.controller.js').default;
export type Scale = import('../../core/core.scale.js').default;
export type PointElement = import('../../elements/element.point.js').default;
import { LineElement } from "../../elements/index.js";

View file

@ -0,0 +1,30 @@
/**
* @typedef { import('../../core/core.scale.js').default } Scale
* @typedef { import('../../elements/element.line.js').default } LineElement
* @typedef { import('../../types/index.js').FillTarget } FillTarget
* @typedef { import('../../types/index.js').ComplexFillTarget } ComplexFillTarget
*/
export function _resolveTarget(sources: any, index: any, propagate: any): any;
/**
* @param {LineElement} line
* @param {number} index
* @param {number} count
*/
export function _decodeFill(line: LineElement, index: number, count: number): any;
/**
* @param {FillTarget | ComplexFillTarget} fill
* @param {Scale} scale
* @returns {number | null}
*/
export function _getTargetPixel(fill: FillTarget | ComplexFillTarget, scale: Scale): number | null;
/**
* @param {FillTarget | ComplexFillTarget} fill
* @param {Scale} scale
* @param {number} startValue
* @returns {number | undefined}
*/
export function _getTargetValue(fill: FillTarget | ComplexFillTarget, scale: Scale, startValue: number): number | undefined;
export type Scale = import('../../core/core.scale.js').default;
export type LineElement = import('../../elements/element.line.js').default;
export type FillTarget = import('../../types/index.js').FillTarget;
export type ComplexFillTarget = import('../../types/index.js').ComplexFillTarget;

View file

@ -0,0 +1,36 @@
export function _segments(line: any, target: any, property: any): ({
source: any;
target: {
property: any;
start: any;
end: any;
};
start: any;
end: any;
} | {
source: {
start: number;
end: number;
loop: boolean;
style?: any;
};
target: {
start: number;
end: number;
loop: boolean;
style?: any;
};
start: {
[x: number]: any;
};
end: {
[x: number]: any;
};
})[];
export function _getBounds(property: any, first: any, last: any, loop: any): {
property: any;
start: any;
end: any;
};
export function _pointsFromSegments(boundary: any, line: any): any[];
export function _findSegmentEnd(start: any, end: any, points: any): any;

View file

@ -0,0 +1,9 @@
/**
* @typedef { import('../../core/core.controller.js').default } Chart
* @typedef { import('../../core/core.scale.js').default } Scale
* @typedef { import('../../elements/element.point.js').default } PointElement
*/
export function _getTarget(source: any): any;
export type Chart = import('../../core/core.controller.js').default;
export type Scale = import('../../core/core.scale.js').default;
export type PointElement = import('../../elements/element.point.js').default;

View file

@ -0,0 +1,14 @@
/**
* @param {{ chart: Chart; scale: Scale; index: number; line: LineElement; }} source
* @return {LineElement}
*/
export function _buildStackLine(source: {
chart: Chart;
scale: Scale;
index: number;
line: LineElement;
}): LineElement;
export type Chart = import('../../core/core.controller.js').default;
export type Scale = import('../../core/core.scale.js').default;
export type PointElement = import('../../elements/element.point.js').default;
import { LineElement } from "../../elements/index.js";

View file

@ -0,0 +1,16 @@
declare namespace _default {
const id: string;
function afterDatasetsUpdate(chart: any, _args: any, options: any): void;
function afterDatasetsUpdate(chart: any, _args: any, options: any): void;
function beforeDraw(chart: any, _args: any, options: any): void;
function beforeDraw(chart: any, _args: any, options: any): void;
function beforeDatasetsDraw(chart: any, _args: any, options: any): void;
function beforeDatasetsDraw(chart: any, _args: any, options: any): void;
function beforeDatasetDraw(chart: any, args: any, options: any): void;
function beforeDatasetDraw(chart: any, args: any, options: any): void;
namespace defaults {
const propagate: boolean;
const drawTime: string;
}
}
export default _default;

View file

@ -0,0 +1,12 @@
export class simpleArc {
constructor(opts: any);
x: any;
y: any;
radius: any;
pathSegment(ctx: any, bounds: any, opts: any): boolean;
interpolate(point: any): {
x: any;
y: any;
angle: any;
};
}

View file

@ -0,0 +1,121 @@
export class Legend extends Element<import("../types/basic.js").AnyObject, import("../types/basic.js").AnyObject> {
/**
* @param {{ ctx: any; options: any; chart: any; }} config
*/
constructor(config: {
ctx: any;
options: any;
chart: any;
});
_added: boolean;
legendHitBoxes: any[];
/**
* @private
*/
private _hoveredItem;
doughnutMode: boolean;
chart: any;
options: any;
ctx: any;
legendItems: any;
columnSizes: any[];
lineWidths: number[];
maxHeight: any;
maxWidth: any;
top: any;
bottom: any;
left: any;
right: any;
height: any;
width: any;
_margins: any;
position: any;
weight: any;
fullSize: any;
update(maxWidth: any, maxHeight: any, margins: any): void;
setDimensions(): void;
buildLabels(): void;
fit(): void;
/**
* @private
*/
private _fitRows;
_fitCols(titleHeight: any, labelFont: any, boxWidth: any, _itemHeight: any): any;
adjustHitBoxes(): void;
isHorizontal(): boolean;
draw(): void;
/**
* @private
*/
private _draw;
/**
* @protected
*/
protected drawTitle(): void;
/**
* @private
*/
private _computeTitleHeight;
/**
* @private
*/
private _getLegendItemAt;
/**
* Handle an event
* @param {ChartEvent} e - The event to handle
*/
handleEvent(e: ChartEvent): void;
}
declare namespace _default {
export const id: string;
export { Legend as _element };
export function start(chart: any, _args: any, options: any): void;
export function start(chart: any, _args: any, options: any): void;
export function stop(chart: any): void;
export function stop(chart: any): void;
export function beforeUpdate(chart: any, _args: any, options: any): void;
export function beforeUpdate(chart: any, _args: any, options: any): void;
export function afterUpdate(chart: any): void;
export function afterUpdate(chart: any): void;
export function afterEvent(chart: any, args: any): void;
export function afterEvent(chart: any, args: any): void;
export namespace defaults {
const display: boolean;
const position: string;
const align: string;
const fullSize: boolean;
const reverse: boolean;
const weight: number;
function onClick(e: any, legendItem: any, legend: any): void;
function onClick(e: any, legendItem: any, legend: any): void;
const onHover: any;
const onLeave: any;
namespace labels {
function color(ctx: any): any;
const boxWidth: number;
const padding: number;
function generateLabels(chart: any): any;
function generateLabels(chart: any): any;
}
namespace title {
export function color_1(ctx: any): any;
export { color_1 as color };
const display_1: boolean;
export { display_1 as display };
const position_1: string;
export { position_1 as position };
export const text: string;
}
}
export namespace descriptors {
export function _scriptable(name: any): boolean;
export namespace labels_1 {
export function _scriptable_1(name: any): boolean;
export { _scriptable_1 as _scriptable };
}
export { labels_1 as labels };
}
}
export default _default;
export type ChartEvent = import('../types/index.js').ChartEvent;
import Element from "../core/core.element.js";

View file

@ -0,0 +1,30 @@
declare namespace _default {
const id: string;
function start(chart: any, _args: any, options: any): void;
function start(chart: any, _args: any, options: any): void;
function stop(chart: any): void;
function stop(chart: any): void;
function beforeUpdate(chart: any, _args: any, options: any): void;
function beforeUpdate(chart: any, _args: any, options: any): void;
namespace defaults {
export const align: string;
export const display: boolean;
export namespace font {
const weight: string;
}
export const fullSize: boolean;
export const padding: number;
export const position: string;
export const text: string;
const weight_1: number;
export { weight_1 as weight };
}
namespace defaultRoutes {
const color: string;
}
namespace descriptors {
const _scriptable: boolean;
const _indexable: boolean;
}
}
export default _default;

View file

@ -0,0 +1,64 @@
export class Title extends Element<import("../types/basic.js").AnyObject, import("../types/basic.js").AnyObject> {
/**
* @param {{ ctx: any; options: any; chart: any; }} config
*/
constructor(config: {
ctx: any;
options: any;
chart: any;
});
chart: any;
options: any;
ctx: any;
_padding: import("../types.js").ChartArea;
top: number;
bottom: any;
left: number;
right: any;
width: any;
height: any;
position: any;
weight: any;
fullSize: any;
update(maxWidth: any, maxHeight: any): void;
isHorizontal(): boolean;
_drawArgs(offset: any): {
titleX: any;
titleY: any;
maxWidth: number;
rotation: number;
};
draw(): void;
}
declare namespace _default {
export const id: string;
export { Title as _element };
export function start(chart: any, _args: any, options: any): void;
export function start(chart: any, _args: any, options: any): void;
export function stop(chart: any): void;
export function stop(chart: any): void;
export function beforeUpdate(chart: any, _args: any, options: any): void;
export function beforeUpdate(chart: any, _args: any, options: any): void;
export namespace defaults {
export const align: string;
export const display: boolean;
export namespace font {
const weight: string;
}
export const fullSize: boolean;
export const padding: number;
export const position: string;
export const text: string;
const weight_1: number;
export { weight_1 as weight };
}
export namespace defaultRoutes {
const color: string;
}
export namespace descriptors {
const _scriptable: boolean;
const _indexable: boolean;
}
}
export default _default;
import Element from "../core/core.element.js";

View file

@ -0,0 +1,322 @@
export class Tooltip extends Element<import("../types/basic.js").AnyObject, import("../types/basic.js").AnyObject> {
/**
* @namespace Chart.Tooltip.positioners
*/
static positioners: {
/**
* Average mode places the tooltip at the average position of the elements shown
*/
average(items: any): false | {
x: number;
y: number;
};
/**
* Gets the tooltip position nearest of the item nearest to the event position
*/
nearest(items: any, eventPosition: any): false | {
x: any;
y: any;
};
};
constructor(config: any);
opacity: number;
_active: any[];
_eventPosition: any;
_size: {
width: number;
height: number;
};
_cachedAnimations: Readonly<Animations>;
_tooltipItems: any[];
$animations: any;
$context: any;
chart: any;
options: any;
dataPoints: {
chart: import("../core/core.controller.js").default;
label: any;
parsed: any;
raw: any;
formattedValue: any;
dataset: any;
dataIndex: number;
datasetIndex: number;
element: Element<import("../types/basic.js").AnyObject, import("../types/basic.js").AnyObject>;
}[];
title: any;
beforeBody: any;
body: any[];
afterBody: any;
footer: any;
xAlign: any;
yAlign: any;
x: any;
y: any;
height: number;
width: number;
caretX: any;
caretY: any;
labelColors: any[];
labelPointStyles: any[];
labelTextColors: any[];
initialize(options: any): void;
/**
* @private
*/
private _resolveAnimations;
/**
* @protected
*/
protected getContext(): any;
getTitle(context: any, options: any): any;
getBeforeBody(tooltipItems: any, options: any): any;
getBody(tooltipItems: any, options: any): any[];
getAfterBody(tooltipItems: any, options: any): any;
getFooter(tooltipItems: any, options: any): any;
/**
* @private
*/
private _createItems;
update(changed: any, replay: any): void;
drawCaret(tooltipPoint: any, ctx: any, size: any, options: any): void;
getCaretPosition(tooltipPoint: any, size: any, options: any): {
x1: any;
x2: any;
x3: any;
y1: any;
y2: any;
y3: any;
};
drawTitle(pt: any, ctx: any, options: any): void;
/**
* @private
*/
private _drawColorBox;
drawBody(pt: any, ctx: any, options: any): void;
drawFooter(pt: any, ctx: any, options: any): void;
drawBackground(pt: any, ctx: any, tooltipSize: any, options: any): void;
/**
* Update x/y animation targets when _active elements are animating too
* @private
*/
private _updateAnimationTarget;
/**
* Determine if the tooltip will draw anything
* @returns {boolean} True if the tooltip will render
*/
_willRender(): boolean;
draw(ctx: any): void;
/**
* Get active elements in the tooltip
* @returns {Array} Array of elements that are active in the tooltip
*/
getActiveElements(): any[];
/**
* Set active elements in the tooltip
* @param {array} activeElements Array of active datasetIndex/index pairs.
* @param {object} eventPosition Synthetic event position used in positioning
*/
setActiveElements(activeElements: any[], eventPosition: object): void;
_ignoreReplayEvents: boolean;
/**
* Handle an event
* @param {ChartEvent} e - The event to handle
* @param {boolean} [replay] - This is a replayed event (from update)
* @param {boolean} [inChartArea] - The event is inside chartArea
* @returns {boolean} true if the tooltip changed
*/
handleEvent(e: ChartEvent, replay?: boolean, inChartArea?: boolean): boolean;
/**
* Helper for determining the active elements for event
* @param {ChartEvent} e - The event to handle
* @param {InteractionItem[]} lastActive - Previously active elements
* @param {boolean} [replay] - This is a replayed event (from update)
* @param {boolean} [inChartArea] - The event is inside chartArea
* @returns {InteractionItem[]} - Active elements
* @private
*/
private _getActiveElements;
/**
* Determine if the active elements + event combination changes the
* tooltip position
* @param {array} active - Active elements
* @param {ChartEvent} e - Event that triggered the position change
* @returns {boolean} True if the position has changed
*/
_positionChanged(active: any[], e: ChartEvent): boolean;
}
declare namespace _default {
export const id: string;
export { Tooltip as _element };
export { positioners };
export function afterInit(chart: any, _args: any, options: any): void;
export function afterInit(chart: any, _args: any, options: any): void;
export function beforeUpdate(chart: any, _args: any, options: any): void;
export function beforeUpdate(chart: any, _args: any, options: any): void;
export function reset(chart: any, _args: any, options: any): void;
export function reset(chart: any, _args: any, options: any): void;
export function afterDraw(chart: any): void;
export function afterDraw(chart: any): void;
export function afterEvent(chart: any, args: any): void;
export function afterEvent(chart: any, args: any): void;
export namespace defaults {
export const enabled: boolean;
export const external: any;
export const position: string;
export const backgroundColor: string;
export const titleColor: string;
export namespace titleFont {
const weight: string;
}
export const titleSpacing: number;
export const titleMarginBottom: number;
export const titleAlign: string;
export const bodyColor: string;
export const bodySpacing: number;
export const bodyFont: {};
export const bodyAlign: string;
export const footerColor: string;
export const footerSpacing: number;
export const footerMarginTop: number;
export namespace footerFont {
const weight_1: string;
export { weight_1 as weight };
}
export const footerAlign: string;
export const padding: number;
export const caretPadding: number;
export const caretSize: number;
export const cornerRadius: number;
export function boxHeight(ctx: any, opts: any): any;
export function boxWidth(ctx: any, opts: any): any;
export const multiKeyBackground: string;
export const displayColors: boolean;
export const boxPadding: number;
export const borderColor: string;
export const borderWidth: number;
export namespace animation {
const duration: number;
const easing: string;
}
export namespace animations {
namespace numbers {
const type: string;
const properties: string[];
}
namespace opacity {
const easing_1: string;
export { easing_1 as easing };
const duration_1: number;
export { duration_1 as duration };
}
}
export { defaultCallbacks as callbacks };
}
export namespace defaultRoutes {
const bodyFont_1: string;
export { bodyFont_1 as bodyFont };
const footerFont_1: string;
export { footerFont_1 as footerFont };
const titleFont_1: string;
export { titleFont_1 as titleFont };
}
export namespace descriptors {
export function _scriptable(name: any): boolean;
export const _indexable: boolean;
export namespace callbacks {
const _scriptable_1: boolean;
export { _scriptable_1 as _scriptable };
const _indexable_1: boolean;
export { _indexable_1 as _indexable };
}
export namespace animation_1 {
const _fallback: boolean;
}
export { animation_1 as animation };
export namespace animations_1 {
const _fallback_1: string;
export { _fallback_1 as _fallback };
}
export { animations_1 as animations };
}
export const additionalOptionScopes: string[];
}
export default _default;
export type Chart = import('../platform/platform.base.js').Chart;
export type ChartEvent = import('../types/index.js').ChartEvent;
export type ActiveElement = import('../types/index.js').ActiveElement;
export type InteractionItem = import('../core/core.interaction.js').InteractionItem;
import Element from "../core/core.element.js";
import Animations from "../core/core.animations.js";
declare namespace positioners {
/**
* Average mode places the tooltip at the average position of the elements shown
*/
function average(items: any): false | {
x: number;
y: number;
};
/**
* Average mode places the tooltip at the average position of the elements shown
*/
function average(items: any): false | {
x: number;
y: number;
};
/**
* Gets the tooltip position nearest of the item nearest to the event position
*/
function nearest(items: any, eventPosition: any): false | {
x: any;
y: any;
};
/**
* Gets the tooltip position nearest of the item nearest to the event position
*/
function nearest(items: any, eventPosition: any): false | {
x: any;
y: any;
};
}
declare namespace defaultCallbacks {
export { noop as beforeTitle };
export function title(tooltipItems: any): any;
export function title(tooltipItems: any): any;
export { noop as afterTitle };
export { noop as beforeBody };
export { noop as beforeLabel };
export function label(tooltipItem: any): any;
export function label(tooltipItem: any): any;
export function labelColor(tooltipItem: any): {
borderColor: any;
backgroundColor: any;
borderWidth: any;
borderDash: any;
borderDashOffset: any;
borderRadius: number;
};
export function labelColor(tooltipItem: any): {
borderColor: any;
backgroundColor: any;
borderWidth: any;
borderDash: any;
borderDashOffset: any;
borderRadius: number;
};
export function labelTextColor(): any;
export function labelTextColor(): any;
export function labelPointStyle(tooltipItem: any): {
pointStyle: any;
rotation: any;
};
export function labelPointStyle(tooltipItem: any): {
pointStyle: any;
rotation: any;
};
export { noop as afterLabel };
export { noop as afterBody };
export { noop as beforeFooter };
export { noop as footer };
export { noop as afterFooter };
}
import { noop } from "../helpers/helpers.core.js";

View file

@ -0,0 +1,6 @@
export { default as CategoryScale } from "./scale.category.js";
export { default as LinearScale } from "./scale.linear.js";
export { default as LogarithmicScale } from "./scale.logarithmic.js";
export { default as RadialLinearScale } from "./scale.radialLinear.js";
export { default as TimeScale } from "./scale.time.js";
export { default as TimeSeriesScale } from "./scale.timeseries.js";

View file

@ -0,0 +1,21 @@
export default class CategoryScale extends Scale {
static id: string;
/**
* @type {any}
*/
static defaults: any;
/** @type {number} */
_startValue: number;
_valueRange: number;
_addedLabels: any[];
init(scaleOptions: any): void;
parse(raw: any, index: any): number;
buildTicks(): {
value: any;
}[];
getLabelForValue(value: any): any;
getPixelForValue(value: any): number;
getPixelForTick(index: any): number;
getValueForPixel(pixel: any): number;
}
import Scale from "../core/core.scale.js";

View file

@ -0,0 +1,10 @@
export default class LinearScale extends LinearScaleBase {
static id: string;
/**
* @type {any}
*/
static defaults: any;
getPixelForValue(value: any): number;
getValueForPixel(pixel: any): number;
}
import LinearScaleBase from "./scale.linearbase.js";

View file

@ -0,0 +1,20 @@
export default class LinearScaleBase extends Scale {
/** @type {number} */
start: number;
/** @type {number} */
end: number;
/** @type {number} */
_startValue: number;
/** @type {number} */
_endValue: number;
_valueRange: number;
parse(raw: any, index: any): number;
handleTickRangeOptions(): void;
getTickLimit(): number;
/**
* @protected
*/
protected computeTickLimit(): number;
getLabelForValue(value: any): string;
}
import Scale from "../core/core.scale.js";

View file

@ -0,0 +1,25 @@
export default class LogarithmicScale extends Scale {
static id: string;
/**
* @type {any}
*/
static defaults: any;
/** @type {number} */
start: number;
/** @type {number} */
end: number;
/** @type {number} */
_startValue: number;
_valueRange: number;
parse(raw: any, index: any): number;
_zero: boolean;
handleTickRangeOptions(): void;
/**
* @param {number} value
* @return {string}
*/
getLabelForValue(value: number): string;
getPixelForValue(value: any): number;
getValueForPixel(pixel: any): number;
}
import Scale from "../core/core.scale.js";

View file

@ -0,0 +1,63 @@
export default class RadialLinearScale extends LinearScaleBase {
static id: string;
/**
* @type {any}
*/
static defaults: any;
static defaultRoutes: {
'angleLines.color': string;
'pointLabels.color': string;
'ticks.color': string;
};
static descriptors: {
angleLines: {
_fallback: string;
};
};
/** @type {number} */
xCenter: number;
/** @type {number} */
yCenter: number;
/** @type {number} */
drawingArea: number;
/** @type {string[]} */
_pointLabels: string[];
_pointLabelItems: any[];
_padding: import("../types.js").ChartArea;
generateTickLabels(ticks: any): void;
setCenterPoint(leftMovement: any, rightMovement: any, topMovement: any, bottomMovement: any): void;
getIndexAngle(index: any): number;
getDistanceFromCenterForValue(value: any): number;
getValueForDistanceFromCenter(distance: any): any;
getPointLabelContext(index: any): any;
getPointPosition(index: any, distanceFromCenter: any, additionalAngle?: number): {
x: number;
y: number;
angle: number;
};
getPointPositionForValue(index: any, value: any): {
x: number;
y: number;
angle: number;
};
getBasePosition(index: any): {
x: number;
y: number;
angle: number;
};
getPointLabelPosition(index: any): {
left: any;
top: any;
right: any;
bottom: any;
};
/**
* @protected
*/
protected drawGrid(): void;
/**
* @protected
*/
protected drawLabels(): void;
}
import LinearScaleBase from "./scale.linearbase.js";

View file

@ -0,0 +1,124 @@
export default class TimeScale extends Scale {
static id: string;
/**
* @type {any}
*/
static defaults: any;
/**
* @param {object} props
*/
constructor(props: object);
/** @type {{data: number[], labels: number[], all: number[]}} */
_cache: {
data: number[];
labels: number[];
all: number[];
};
/** @type {Unit} */
_unit: Unit;
/** @type {Unit=} */
_majorUnit: Unit | undefined;
_offsets: {};
_normalized: boolean;
_parseOpts: {
parser: any;
round: any;
isoWeekday: any;
};
init(scaleOpts: any, opts?: {}): void;
_adapter: DateAdapter;
/**
* @param {*} raw
* @param {number?} [index]
* @return {number}
*/
parse(raw: any, index?: number | null): number;
/**
* @private
*/
private _getLabelBounds;
/**
* Returns the start and end offsets from edges in the form of {start, end}
* where each value is a relative width to the scale and ranges between 0 and 1.
* They add extra margins on the both sides by scaling down the original scale.
* Offsets are added when the `offset` option is true.
* @param {number[]} timestamps
* @protected
*/
protected initOffsets(timestamps?: number[]): void;
/**
* Generates a maximum of `capacity` timestamps between min and max, rounded to the
* `minor` unit using the given scale time `options`.
* Important: this method can return ticks outside the min and max range, it's the
* responsibility of the calling code to clamp values if needed.
* @private
*/
private _generate;
/**
* @param {number} value
* @return {string}
*/
getLabelForValue(value: number): string;
/**
* Function to format an individual tick mark
* @param {number} time
* @param {number} index
* @param {object[]} ticks
* @param {string|undefined} [format]
* @return {string}
* @private
*/
private _tickFormatFunction;
/**
* @param {object[]} ticks
*/
generateTickLabels(ticks: object[]): void;
/**
* @param {number} value - Milliseconds since epoch (1 January 1970 00:00:00 UTC)
* @return {number}
*/
getDecimalForValue(value: number): number;
/**
* @param {number} value - Milliseconds since epoch (1 January 1970 00:00:00 UTC)
* @return {number}
*/
getPixelForValue(value: number): number;
/**
* @param {number} pixel
* @return {number}
*/
getValueForPixel(pixel: number): number;
/**
* @param {string} label
* @return {{w:number, h:number}}
* @private
*/
private _getLabelSize;
/**
* @param {number} exampleTime
* @return {number}
* @private
*/
private _getLabelCapacity;
/**
* @protected
*/
protected getDataTimestamps(): any;
/**
* @protected
*/
protected getLabelTimestamps(): number[];
/**
* @param {number[]} values
* @protected
*/
protected normalize(values: number[]): number[];
}
export type Unit = import('../core/core.adapters.js').TimeUnit;
export type Interval = {
common: boolean;
size: number;
steps?: number;
};
export type DateAdapter = import('../core/core.adapters.js').DateAdapter;
import Scale from "../core/core.scale.js";

View file

@ -0,0 +1,32 @@
export default TimeSeriesScale;
declare class TimeSeriesScale extends TimeScale {
/** @type {object[]} */
_table: object[];
/** @type {number} */
_minPos: number;
/** @type {number} */
_tableRange: number;
/**
* @protected
*/
protected initOffsets(): void;
/**
* Returns an array of {time, pos} objects used to interpolate a specific `time` or position
* (`pos`) on the scale, by searching entries before and after the requested value. `pos` is
* a decimal between 0 and 1: 0 being the start of the scale (left or top) and 1 the other
* extremity (left + width or top + height). Note that it would be more optimized to directly
* store pre-computed pixels, but the scale dimensions are not guaranteed at the time we need
* to create the lookup table. The table ALWAYS contains at least two items: min and max.
* @param {number[]} timestamps
* @return {object[]}
* @protected
*/
protected buildLookupTable(timestamps: number[]): object[];
/**
* Returns all timestamps
* @return {number[]}
* @private
*/
private _getTimestampsForTable;
}
import TimeScale from "./scale.time.js";

View file

@ -0,0 +1,10 @@
/**
* Temporary entry point of the types at the time of the transition.
* After transition done need to remove it in favor of index.ts
*/
export * from './index.js';
/**
* Explicitly re-exporting to resolve the ambiguity.
*/
export { BarController, BubbleController, DoughnutController, LineController, PieController, PolarAreaController, RadarController, ScatterController, Animation, Animations, Chart, DatasetController, Interaction, Scale, Ticks, defaults, layouts, registry, ArcElement, BarElement, LineElement, PointElement, BasePlatform, BasicPlatform, DomPlatform, Decimation, Filler, Legend, SubTitle, Title, Tooltip, CategoryScale, LinearScale, LogarithmicScale, RadialLinearScale, TimeScale, TimeSeriesScale, registerables } from './types/index.js';
export * from './types/index.js';

View file

@ -0,0 +1,34 @@
import {Chart} from './index.js';
import {AnyObject} from './basic.js';
export declare class Animation {
constructor(cfg: AnyObject, target: AnyObject, prop: string, to?: unknown);
active(): boolean;
update(cfg: AnyObject, to: unknown, date: number): void;
cancel(): void;
tick(date: number): void;
readonly _to: unknown;
}
export interface AnimationEvent {
chart: Chart;
numSteps: number;
initial: boolean;
currentStep: number;
}
export declare class Animator {
listen(chart: Chart, event: 'complete' | 'progress', cb: (event: AnimationEvent) => void): void;
add(chart: Chart, items: readonly Animation[]): void;
has(chart: Chart): boolean;
start(chart: Chart): void;
running(chart: Chart): boolean;
stop(chart: Chart): void;
remove(chart: Chart): boolean;
}
export declare class Animations {
constructor(chart: Chart, animations: AnyObject);
configure(animations: AnyObject): void;
update(target: AnyObject, values: AnyObject): undefined | boolean;
}

View file

@ -0,0 +1,3 @@
export type AnyObject = Record<string, any>;
export type EmptyObject = Record<string, never>;

Some files were not shown because too many files have changed in this diff Show more