}
export type AnyObject = Record<string, unknown>;
-export interface Defaults extends CoreChartOptions, ElementChartOptions {
+export interface Defaults extends CoreChartOptions, ElementChartOptions, PluginChartOptions {
controllers: {
[key in ChartType]: DeepPartial<
CoreChartOptions &
ElementChartOptions &
+ PluginChartOptions &
DatasetChartOptions<key>[key] &
ScaleChartOptions<key> &
ChartTypeRegistry[key]['chartOptions']
>;
};
- scale: ScaleOptions;
+ scale: ScaleOptionsByType;
scales: {
- [key in ScaleType]: ScaleOptions<key>;
+ [key in ScaleType]: ScaleOptionsByType<key>;
};
- plugins: PluginOptions;
-
set(values: AnyObject): AnyObject;
set(scope: string, values: AnyObject): AnyObject;
get(scope: string): AnyObject;
* @see Defaults.color
*/
color: Color;
- /**
+ /**
* base background color
* @see Defaults.backgroundColor
*/
backgroundColor: Color;
- /**
+ /**
* base border color
* @see Defaults.borderColor
*/
layout: {
padding: Scriptable<number | ChartArea, ScriptableContext>;
};
-
- plugins: PluginOptions;
}
export type EasingFunction =
getRange?(axis: 'x' | 'y'): number;
}
-export interface CommonOptions {
+export interface CommonElementOptions {
borderWidth: number;
borderColor: Color;
backgroundColor: Color;
circumference: number;
}
-export interface ArcOptions extends CommonOptions {
+export interface ArcOptions extends CommonElementOptions {
/**
* Arc stroke alignment.
*/
export interface LineProps {}
-export interface LineOptions extends CommonOptions {
+export interface LineOptions extends CommonElementOptions {
/**
* Line cap style. See MDN.
* @default 'butt'
| HTMLImageElement
| HTMLCanvasElement;
-export interface PointOptions extends CommonOptions {
+export interface PointOptions extends CommonElementOptions {
/**
* Point radius
* @default 3
height: number;
}
-export interface BarOptions extends CommonOptions {
+export interface BarOptions extends CommonElementOptions {
/**
* The base value for the bar in data units along the value axis.
*/
new (cfg: any): BarElement;
};
-export interface ElementOptions {
+export interface ElementOptionsByType {
arc: ArcOptions & ArcHoverOptions;
bar: BarOptions & BarHoverOptions;
line: LineOptions & LineHoverOptions;
point: PointOptions & PointHoverOptions;
}
export interface ElementChartOptions {
- elements: ElementOptions;
+ elements: Partial<ElementOptionsByType>;
}
export class BasePlatform {
element: Element;
}
-export interface PluginOptions {
+export interface PluginOptionsByType {
filler: FillerOptions;
legend: LegendOptions;
title: TitleOptions;
tooltip: TooltipOptions;
}
+export interface PluginChartOptions {
+ plugins: Partial<PluginOptionsByType>;
+}
+
export interface GridLineOptions {
/**
* @default true
export type ChartType = keyof ChartTypeRegistry;
-export type ScaleOptions<TScale extends ScaleType = ScaleType> = DeepPartial<
+export type ScaleOptionsByType<TScale extends ScaleType = ScaleType> = DeepPartial<
{ [key in ScaleType]: { type: key } & ScaleTypeRegistry[key]['options'] }[TScale]
>;
export type ScaleChartOptions<TType extends ChartType = ChartType> = {
scales: {
- [key: string]: ScaleOptions<ChartTypeRegistry[TType]['scales']>;
+ [key: string]: ScaleOptionsByType<ChartTypeRegistry[TType]['scales']>;
};
};
export type ChartOptions<TType extends ChartType = ChartType> = DeepPartial<
CoreChartOptions &
ElementChartOptions &
+ PluginChartOptions &
DatasetChartOptions<TType> &
ScaleChartOptions<TType> &
ChartTypeRegistry[TType]['chartOptions']