import { TimeUnit } from './adapters';
import { AnimationEvent } from './animation';
+import { AnyObject, EmptyObject } from './basic';
import { Color } from './color';
import { Element } from './element';
import { ChartArea, Point } from './geometric';
export interface ScriptableContext {
chart: Chart;
- dataPoint: any;
+ parsed: unknown[];
+ raw: unknown[];
dataIndex: number;
dataset: ChartDataset;
datasetIndex: number;
skipNull?: boolean;
}
-export interface BarController extends DatasetController {}
+export type BarController = DatasetController
export const BarController: ChartComponent & {
prototype: BarController;
new (chart: Chart, datasetIndex: number): BarController;
r: number;
}
-export interface BubbleController extends DatasetController {}
+export type BubbleController = DatasetController
export const BubbleController: ChartComponent & {
prototype: BubbleController;
new (chart: Chart, datasetIndex: number): BubbleController;
showLine: boolean;
}
-export interface LineController extends DatasetController {}
+export type LineController = DatasetController
export const LineController: ChartComponent & {
prototype: LineController;
new (chart: Chart, datasetIndex: number): LineController;
export type ScatterControllerChartOptions = LineControllerChartOptions;
-export interface ScatterController extends LineController {}
+export type ScatterController = LineController
export const ScatterController: ChartComponent & {
prototype: ScatterController;
new (chart: Chart, datasetIndex: number): ScatterController;
export type PieDataPoint = DoughnutDataPoint;
-export interface PieController extends DoughnutController {}
+export type PieController = DoughnutController
export const PieController: ChartComponent & {
prototype: PieController;
new (chart: Chart, datasetIndex: number): PieController;
export type RadarControllerChartOptions = LineControllerChartOptions;
-export interface RadarController extends DatasetController {}
+export type RadarController = DatasetController
export const RadarController: ChartComponent & {
prototype: RadarController;
new (chart: Chart, datasetIndex: number): RadarController;
_sorted: boolean;
_stacked: boolean;
- _parsed: any[];
+ _parsed: unknown[];
}
export interface ActiveDataPoint {
setActiveElements(active: ActiveDataPoint[]): void;
destroy(): void;
- toBase64Image(type?: string, quality?: any): string;
+ toBase64Image(type?: string, quality?: unknown): string;
bindEvents(): void;
unbindEvents(): void;
updateHoverStyle(items: Element, mode: 'dataset', enabled: boolean): void;
notifyPlugins(hook: string, args?: AnyObject): boolean | void;
+ static readonly defaults: Defaults;
static readonly version: string;
static readonly instances: { [key: string]: Chart };
static readonly registry: Registry;
addElements(): void;
buildOrUpdateElements(resetNewElements?: boolean): void;
- getStyle(index: number, active: boolean): any;
- protected resolveDatasetElementOptions(active: boolean): any;
- protected resolveDataElementOptions(index: number, mode: UpdateMode): any;
+ getStyle(index: number, active: boolean): AnyObject;
+ protected resolveDatasetElementOptions(active: boolean): AnyObject;
+ protected resolveDataElementOptions(index: number, mode: UpdateMode): AnyObject;
/**
* Utility for checking if the options are shared and should be animated separately.
* @protected
*/
- protected getSharedOptions(options: any): undefined | any;
+ protected getSharedOptions(options: AnyObject): undefined | AnyObject;
/**
* Utility for determining if `options` should be included in the updated properties
* @protected
*/
- protected includeOptions(mode: UpdateMode, sharedOptions: any): boolean;
+ protected includeOptions(mode: UpdateMode, sharedOptions: AnyObject): boolean;
/**
* Utility for updating an element with new properties, using animations when appropriate.
* @protected
*/
- protected updateElement(element: TElement | TDatasetElement, index: number | undefined, properties: any, mode: UpdateMode): void;
+ protected updateElement(element: TElement | TDatasetElement, index: number | undefined, properties: AnyObject, mode: UpdateMode): void;
/**
* Utility to animate the shared options, that are potentially affecting multiple elements.
* @protected
*/
- protected updateSharedOptions(sharedOptions: any, mode: UpdateMode, newOptions: any): void;
+ protected updateSharedOptions(sharedOptions: AnyObject, mode: UpdateMode, newOptions: AnyObject): void;
removeHoverStyle(element: TElement, datasetIndex: number, index: number): void;
setHoverStyle(element: TElement, datasetIndex: number, index: number): void;
parse(start: number, count: number): void;
- protected parsePrimitiveData(meta: ChartMeta<TElement, TDatasetElement>, data: any[], start: number, count: number): any[];
- protected parseArrayData(meta: ChartMeta<TElement, TDatasetElement>, data: any[], start: number, count: number): any[];
- protected parseObjectData(meta: ChartMeta<TElement, TDatasetElement>, data: any[], start: number, count: number): any[];
- protected getParsed(index: number): any;
- protected applyStack(scale: Scale, parsed: any[]): number;
+ protected parsePrimitiveData(meta: ChartMeta<TElement, TDatasetElement>, data: AnyObject[], start: number, count: number): AnyObject[];
+ protected parseArrayData(meta: ChartMeta<TElement, TDatasetElement>, data: AnyObject[], start: number, count: number): AnyObject[];
+ protected parseObjectData(meta: ChartMeta<TElement, TDatasetElement>, data: AnyObject[], start: number, count: number): AnyObject[];
+ protected getParsed(index: number): AnyObject;
+ protected applyStack(scale: Scale, parsed: unknown[]): number;
protected updateRangeFromParsed(
range: { min: number; max: number },
scale: Scale,
- parsed: any[],
+ parsed: unknown[],
stack: boolean
): void;
protected getMinMax(scale: Scale, canStack?: boolean): { min: number; max: number };
};
}
-export type AnyObject = Record<string, unknown>;
export interface Defaults extends CoreChartOptions, ElementChartOptions, PluginChartOptions {
controllers: {
[key in ChartType]: DeepPartial<
update(chart: Chart, width: number, height: number): void;
};
-export interface Plugin<O = {}> extends ExtendedPlugin {
+export interface Plugin<O = AnyObject> extends ExtendedPlugin {
id: string;
/**
* @param {object} options - The plugin options.
* @since 3.0.0
*/
- install?(chart: Chart, args: {}, options: O): void;
+ install?(chart: Chart, args: EmptyObject, options: O): void;
/**
* @desc Called when a plugin is starting. This happens when chart is created or plugin is enabled.
* @param {Chart} chart - The chart instance.
* @param {object} options - The plugin options.
* @since 3.0.0
*/
- start?(chart: Chart, args: {}, options: O): void;
+ start?(chart: Chart, args: EmptyObject, options: O): void;
/**
* @desc Called when a plugin stopping. This happens when chart is destroyed or plugin is disabled.
* @param {Chart} chart - The chart instance.
* @param {object} options - The plugin options.
* @since 3.0.0
*/
- stop?(chart: Chart, args: {}, options: O): void;
+ stop?(chart: Chart, args: EmptyObject, options: O): void;
/**
* @desc Called before initializing `chart`.
* @param {Chart} chart - The chart instance.
* @param {object} args - The call arguments.
* @param {object} options - The plugin options.
*/
- beforeInit?(chart: Chart, args: {}, options: O): void;
+ beforeInit?(chart: Chart, args: EmptyObject, options: O): void;
/**
* @desc Called after `chart` has been initialized and before the first update.
* @param {Chart} chart - The chart instance.
* @param {object} args - The call arguments.
* @param {object} options - The plugin options.
*/
- afterInit?(chart: Chart, args: {}, options: O): void;
+ afterInit?(chart: Chart, args: EmptyObject, options: O): void;
/**
* @desc Called before updating `chart`. If any plugin returns `false`, the update
* is cancelled (and thus subsequent render(s)) until another `update` is triggered.
* @param {object} options - The plugin options.
* @returns {boolean} `false` to cancel the chart update.
*/
- beforeUpdate?(chart: Chart, args: { mode: UpdateMode }, options: O): boolean | void;
+ beforeUpdate?(chart: Chart, args: { mode: UpdateMode, cancelable: true }, options: O): boolean | void;
/**
* @desc Called after `chart` has been updated and before rendering. Note that this
* hook will not be called if the chart update has been previously cancelled.
* @param {object} args - The call arguments.
* @param {object} options - The plugin options.
*/
- beforeElementsUpdate?(chart: Chart, args: {}, options: O): void;
+ beforeElementsUpdate?(chart: Chart, args: EmptyObject, options: O): void;
/**
* @desc Called during chart reset
* @param {Chart} chart - The chart instance.
* @param {object} options - The plugin options.
* @since version 3.0.0
*/
- reset?(chart: Chart, args: {}, options: O): void;
+ reset?(chart: Chart, args: EmptyObject, options: O): void;
/**
* @desc Called before updating the `chart` datasets. If any plugin returns `false`,
* the datasets update is cancelled until another `update` is triggered.
* @param {object} options - The plugin options.
* @since version 2.1.5
*/
- afterDatasetsUpdate?(chart: Chart, args: { mode: UpdateMode }, options: O): void;
+ afterDatasetsUpdate?(chart: Chart, args: { mode: UpdateMode, cancelable: true }, options: O): void;
/**
* @desc Called before updating the `chart` dataset at the given `args.index`. If any plugin
* returns `false`, the datasets update is cancelled until another `update` is triggered.
* @param {object} options - The plugin options.
* @returns {boolean} `false` to cancel the chart datasets drawing.
*/
- beforeDatasetUpdate?(chart: Chart, args: { index: number; meta: ChartMeta, mode: UpdateMode }, options: O): boolean | void;
+ beforeDatasetUpdate?(chart: Chart, args: { index: number; meta: ChartMeta, mode: UpdateMode, cancelable: true }, options: O): boolean | void;
/**
* @desc Called after the `chart` datasets at the given `args.index` has been updated. Note
* that this hook will not be called if the datasets update has been previously cancelled.
* @param {UpdateMode} args.mode - The update mode.
* @param {object} options - The plugin options.
*/
- afterDatasetUpdate?(chart: Chart, args: { index: number; meta: ChartMeta, mode: UpdateMode }, options: O): void;
+ afterDatasetUpdate?(chart: Chart, args: { index: number; meta: ChartMeta, mode: UpdateMode, cancelable: false }, options: O): void;
/**
* @desc Called before laying out `chart`. If any plugin returns `false`,
* the layout update is cancelled until another `update` is triggered.
* @param {object} options - The plugin options.
* @returns {boolean} `false` to cancel the chart layout.
*/
- beforeLayout?(chart: Chart, args: {}, options: O): boolean | void;
+ beforeLayout?(chart: Chart, args: { cancelable: true }, options: O): boolean | void;
/**
* @desc Called before scale data limits are calculated. This hook is called separately for each scale in the chart.
* @param {Chart} chart - The chart instance.
* @param {object} args - The call arguments.
* @param {object} options - The plugin options.
*/
- afterLayout?(chart: Chart, args: {}, options: O): void;
+ afterLayout?(chart: Chart, args: EmptyObject, options: O): void;
/**
* @desc Called before rendering `chart`. If any plugin returns `false`,
* the rendering is cancelled until another `render` is triggered.
* @param {object} options - The plugin options.
* @returns {boolean} `false` to cancel the chart rendering.
*/
- beforeRender?(chart: Chart, args: {}, options: O): boolean | void;
+ beforeRender?(chart: Chart, args: { cancelable: true }, options: O): boolean | void;
/**
* @desc Called after the `chart` has been fully rendered (and animation completed). Note
* that this hook will not be called if the rendering has been previously cancelled.
* @param {object} args - The call arguments.
* @param {object} options - The plugin options.
*/
- afterRender?(chart: Chart, args: {}, options: O): void;
+ afterRender?(chart: Chart, args: EmptyObject, options: O): void;
/**
* @desc Called before drawing `chart` at every animation frame. If any plugin returns `false`,
* the frame drawing is cancelled untilanother `render` is triggered.
* @param {object} options - The plugin options.
* @returns {boolean} `false` to cancel the chart drawing.
*/
- beforeDraw?(chart: Chart, args: {}, options: O): boolean | void;
+ beforeDraw?(chart: Chart, args: { cancelable: true }, options: O): boolean | void;
/**
* @desc Called after the `chart` has been drawn. Note that this hook will not be called
* if the drawing has been previously cancelled.
* @param {object} args - The call arguments.
* @param {object} options - The plugin options.
*/
- afterDraw?(chart: Chart, args: {}, options: O): void;
+ afterDraw?(chart: Chart, args: EmptyObject, options: O): void;
/**
* @desc Called before drawing the `chart` datasets. If any plugin returns `false`,
* the datasets drawing is cancelled until another `render` is triggered.
* @param {object} options - The plugin options.
* @returns {boolean} `false` to cancel the chart datasets drawing.
*/
- beforeDatasetsDraw?(chart: Chart, args: {}, options: O): boolean | void;
+ beforeDatasetsDraw?(chart: Chart, args: { cancelable: true }, options: O): boolean | void;
/**
* @desc Called after the `chart` datasets have been drawn. Note that this hook
* will not be called if the datasets drawing has been previously cancelled.
* @param {object} args - The call arguments.
* @param {object} options - The plugin options.
*/
- afterDatasetsDraw?(chart: Chart, args: {}, options: O): void;
+ afterDatasetsDraw?(chart: Chart, args: EmptyObject, options: O, cancelable: false): void;
/**
* @desc Called before drawing the `chart` dataset at the given `args.index` (datasets
* are drawn in the reverse order). If any plugin returns `false`, the datasets drawing
* @param {boolean} args.replay - True if this event is replayed from `Chart.update`
* @param {object} options - The plugin options.
*/
- beforeEvent?(chart: Chart, args: { event: ChartEvent, replay: boolean }, options: O): boolean | void;
+ beforeEvent?(chart: Chart, args: { event: ChartEvent, replay: boolean, cancelable: true }, options: O): boolean | void;
/**
* @desc Called after the `event` has been consumed. Note that this hook
* will not be called if the `event` has been previously discarded.
* @param {boolean} [args.changed] - Set to true if the plugin needs a render. Should only be changed to true, because this args object is passed through all plugins.
* @param {object} options - The plugin options.
*/
- afterEvent?(chart: Chart, args: { event: ChartEvent, replay: boolean, changed?: boolean }, options: O): void;
+ afterEvent?(chart: Chart, args: { event: ChartEvent, replay: boolean, changed?: boolean, cancelable: false }, options: O): void;
/**
* @desc Called after the chart as been resized.
* @param {Chart} chart - The chart instance.
* @param {object} args - The call arguments.
* @param {object} options - The plugin options.
*/
- destroy?(chart: Chart, args: {}, options: O): void;
+ destroy?(chart: Chart, args: EmptyObject, options: O): void;
/**
* Called after chart is destroyed on all plugins that were installed for that chart. This hook is also invoked for disabled plugins (options === false).
* @param {Chart} chart - The chart instance.
* @param {object} options - The plugin options.
* @since 3.0.0
*/
- uninstall?(chart: Chart, args: {}, options: O): void;
+ uninstall?(chart: Chart, args: EmptyObject, options: O): void;
}
export declare type ChartComponentLike = ChartComponent | ChartComponent[] | { [key: string]: ChartComponent };
getBasePixel(): number;
init(options: O): void;
- parse(raw: any, index: number): any;
+ parse(raw: unknown, index: number): unknown;
getUserBounds(): { min: number; max: number; minDefined: boolean; maxDefined: boolean };
getMinMax(canStack: boolean): { min: number; max: number };
getTicks(): Tick[];
}
export const Scale: {
prototype: Scale;
- new <O extends CoreScaleOptions = CoreScaleOptions>(cfg: any): Scale<O>;
+ new <O extends CoreScaleOptions = CoreScaleOptions>(cfg: AnyObject): Scale<O>;
};
export interface ScriptableScaleContext {
* @param value the value to display
* @return {string|string[]} the label to display
*/
- values(value: any): string | string[];
+ values(value: unknown): string | string[];
/**
* Formatter for numeric ticks
* @param tickValue the value to be formatted
}
export interface ChartComponent {
id: string;
- defaults?: any;
+ defaults?: AnyObject;
defaultRoutes?: { [property: string]: string };
beforeRegister?(): void;
export const ArcElement: ChartComponent & {
prototype: ArcElement;
- new (cfg: any): ArcElement;
+ new (cfg: AnyObject): ArcElement;
};
export interface LineProps {}
first(): Point | false;
last(): Point | false;
interpolate(point: Point, property: 'x' | 'y'): undefined | Point | Point[];
- pathSegment(ctx: CanvasRenderingContext2D, segment: Segment, params: any): undefined | boolean;
+ pathSegment(ctx: CanvasRenderingContext2D, segment: Segment, params: AnyObject): undefined | boolean;
path(ctx: CanvasRenderingContext2D): boolean;
}
export const LineElement: ChartComponent & {
prototype: LineElement;
- new (cfg: any): LineElement;
+ new (cfg: AnyObject): LineElement;
};
export interface PointProps {
export const PointElement: ChartComponent & {
prototype: PointElement;
- new (cfg: any): PointElement;
+ new (cfg: AnyObject): PointElement;
};
export interface BarProps {
export const BarElement: ChartComponent & {
prototype: BarElement;
- new (cfg: any): BarElement;
+ new (cfg: AnyObject): BarElement;
};
export interface ElementOptionsByType {
/**
* Parsed data values for the given `dataIndex` and `datasetIndex`
*/
- dataPoint: any;
+ parsed: unknown;
+
+ /**
+ * Raw data values for the given `dataIndex` and `datasetIndex`
+ */
+ raw: unknown;
/**
* Formatted value for the tooltip
/**
* Returns the string representation of the tick value as it should be displayed on the chart. See callback.
*/
- callback: (tickValue: any, index: number, ticks: Tick[]) => string;
+ callback: (tickValue: unknown, index: number, ticks: Tick[]) => string;
/**
* If true, show tick labels.
* @default true
labels: string[] | string[][];
};
-export interface CategoryScale<O extends CategoryScaleOptions = CategoryScaleOptions> extends Scale<O> {}
+export type CategoryScale<O extends CategoryScaleOptions = CategoryScaleOptions> = Scale<O>
export const CategoryScale: ChartComponent & {
prototype: CategoryScale;
- new <O extends CategoryScaleOptions = CategoryScaleOptions>(cfg: any): CategoryScale<O>;
+ new <O extends CategoryScaleOptions = CategoryScaleOptions>(cfg: AnyObject): CategoryScale<O>;
};
export type LinearScaleOptions = CartesianScaleOptions & {
};
};
-export interface LinearScale<O extends LinearScaleOptions = LinearScaleOptions> extends Scale<O> {}
+export type LinearScale<O extends LinearScaleOptions = LinearScaleOptions> = Scale<O>
export const LinearScale: ChartComponent & {
prototype: LinearScale;
- new <O extends LinearScaleOptions = LinearScaleOptions>(cfg: any): LinearScale<O>;
+ new <O extends LinearScaleOptions = LinearScaleOptions>(cfg: AnyObject): LinearScale<O>;
};
export type LogarithmicScaleOptions = CartesianScaleOptions & {
};
};
-export interface LogarithmicScale<O extends LogarithmicScaleOptions = LogarithmicScaleOptions> extends Scale<O> {}
+export type LogarithmicScale<O extends LogarithmicScaleOptions = LogarithmicScaleOptions> = Scale<O>
export const LogarithmicScale: ChartComponent & {
prototype: LogarithmicScale;
- new <O extends LogarithmicScaleOptions = LogarithmicScaleOptions>(cfg: any): LogarithmicScale<O>;
+ new <O extends LogarithmicScaleOptions = LogarithmicScaleOptions>(cfg: AnyObject): LogarithmicScale<O>;
};
export type TimeScaleOptions = CartesianScaleOptions & {
* options for creating a new adapter instance
*/
adapters: {
- date: any;
+ date: unknown;
};
time: {
* Custom parser for dates.
* @see https://www.chartjs.org/docs/next/axes/cartesian/time#parser
*/
- parser: string | ((v: any) => number);
+ parser: string | ((v: unknown) => number);
/**
* If defined, dates will be rounded to the start of this unit. See Time Units below for the allowed units.
*/
export const TimeScale: ChartComponent & {
prototype: TimeScale;
- new <O extends TimeScaleOptions = TimeScaleOptions>(cfg: any): TimeScale<O>;
+ new <O extends TimeScaleOptions = TimeScaleOptions>(cfg: AnyObject): TimeScale<O>;
};
-export interface TimeSeriesScale<O extends TimeScaleOptions = TimeScaleOptions> extends TimeScale<O> {}
+export type TimeSeriesScale<O extends TimeScaleOptions = TimeScaleOptions> = TimeScale<O>
export const TimeSeriesScale: ChartComponent & {
prototype: TimeSeriesScale;
- new <O extends TimeScaleOptions = TimeScaleOptions>(cfg: any): TimeSeriesScale<O>;
+ new <O extends TimeScaleOptions = TimeScaleOptions>(cfg: AnyObject): TimeSeriesScale<O>;
};
export type RadialLinearScaleOptions = CoreScaleOptions & {
}
export const RadialLinearScale: ChartComponent & {
prototype: RadialLinearScale;
- new <O extends RadialLinearScaleOptions = RadialLinearScaleOptions>(cfg: any): RadialLinearScale<O>;
+ new <O extends RadialLinearScaleOptions = RadialLinearScaleOptions>(cfg: AnyObject): RadialLinearScale<O>;
};
// DeepPartial implementation taken from the utility-types NPM package, which is
: T extends object
? _DeepPartialObject<T>
: T | undefined;
- interface _DeepPartialArray<T> extends Array<DeepPartial<T>> {}
+ type _DeepPartialArray<T> = Array<DeepPartial<T>>
type _DeepPartialObject<T> = { [P in keyof T]?: DeepPartial<T[P]> };
export type DistributiveArray<T> = T extends unknown ? T[] : never
scales: keyof CartesianScaleTypeRegistry;
};
bubble: {
- chartOptions: {};
+ chartOptions: EmptyObject;
datasetOptions: BubbleControllerDatasetOptions;
defaultDataPoint: BubbleDataPoint;
scales: keyof CartesianScaleTypeRegistry;