From: Evert Timberg Date: Mon, 1 Feb 2021 13:38:37 +0000 (-0500) Subject: Update type map names (#8356) X-Git-Tag: v3.0.0-beta.10~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=49b0916c19c3f7742094c585258114aa1996a1b2;p=thirdparty%2FChart.js.git Update type map names (#8356) * Rename ElementOptions to ElementOptionsByType * Rename CommonOptions to CommonElementOptions * Rename PluginOptions to PluginOptionsByType Add new PluginChartOptions and remove some duplicates * Rename ScaleOptions to ScaleOptionsByType * Use Partial where appropriate --- diff --git a/types/index.esm.d.ts b/types/index.esm.d.ts index ad1ebdbe3..f78955e01 100644 --- a/types/index.esm.d.ts +++ b/types/index.esm.d.ts @@ -594,24 +594,23 @@ export interface DatasetControllerChartComponent extends ChartComponent { } export type AnyObject = Record; -export interface Defaults extends CoreChartOptions, ElementChartOptions { +export interface Defaults extends CoreChartOptions, ElementChartOptions, PluginChartOptions { controllers: { [key in ChartType]: DeepPartial< CoreChartOptions & ElementChartOptions & + PluginChartOptions & DatasetChartOptions[key] & ScaleChartOptions & ChartTypeRegistry[key]['chartOptions'] >; }; - scale: ScaleOptions; + scale: ScaleOptionsByType; scales: { - [key in ScaleType]: ScaleOptions; + [key in ScaleType]: ScaleOptionsByType; }; - plugins: PluginOptions; - set(values: AnyObject): AnyObject; set(scope: string, values: AnyObject): AnyObject; get(scope: string): AnyObject; @@ -1339,12 +1338,12 @@ export interface CoreChartOptions extends ParsingOptions { * @see Defaults.color */ color: Color; - /** + /** * base background color * @see Defaults.backgroundColor */ backgroundColor: Color; - /** + /** * base border color * @see Defaults.borderColor */ @@ -1411,8 +1410,6 @@ export interface CoreChartOptions extends ParsingOptions { layout: { padding: Scriptable; }; - - plugins: PluginOptions; } export type EasingFunction = @@ -1558,7 +1555,7 @@ export interface VisualElement { getRange?(axis: 'x' | 'y'): number; } -export interface CommonOptions { +export interface CommonElementOptions { borderWidth: number; borderColor: Color; backgroundColor: Color; @@ -1586,7 +1583,7 @@ export interface ArcProps { circumference: number; } -export interface ArcOptions extends CommonOptions { +export interface ArcOptions extends CommonElementOptions { /** * Arc stroke alignment. */ @@ -1612,7 +1609,7 @@ export const ArcElement: ChartComponent & { export interface LineProps {} -export interface LineOptions extends CommonOptions { +export interface LineOptions extends CommonElementOptions { /** * Line cap style. See MDN. * @default 'butt' @@ -1699,7 +1696,7 @@ export type PointStyle = | HTMLImageElement | HTMLCanvasElement; -export interface PointOptions extends CommonOptions { +export interface PointOptions extends CommonElementOptions { /** * Point radius * @default 3 @@ -1800,7 +1797,7 @@ export interface BarProps { 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. */ @@ -1840,14 +1837,14 @@ export const BarElement: ChartComponent & { 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; } export class BasePlatform { @@ -2479,12 +2476,16 @@ export interface TooltipItem { element: Element; } -export interface PluginOptions { +export interface PluginOptionsByType { filler: FillerOptions; legend: LegendOptions; title: TitleOptions; tooltip: TooltipOptions; } +export interface PluginChartOptions { + plugins: Partial; +} + export interface GridLineOptions { /** * @default true @@ -3122,7 +3123,7 @@ export interface ChartTypeRegistry { export type ChartType = keyof ChartTypeRegistry; -export type ScaleOptions = DeepPartial< +export type ScaleOptionsByType = DeepPartial< { [key in ScaleType]: { type: key } & ScaleTypeRegistry[key]['options'] }[TScale] >; @@ -3134,13 +3135,14 @@ export type DatasetChartOptions = { export type ScaleChartOptions = { scales: { - [key: string]: ScaleOptions; + [key: string]: ScaleOptionsByType; }; }; export type ChartOptions = DeepPartial< CoreChartOptions & ElementChartOptions & + PluginChartOptions & DatasetChartOptions & ScaleChartOptions & ChartTypeRegistry[TType]['chartOptions']