From: Evert Timberg Date: Tue, 22 Dec 2020 18:10:25 +0000 (-0500) Subject: Remove duplicate Scriptable definitions (#8223) X-Git-Tag: v3.0.0-beta.8~36 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=55dd7ded0e7c6133c615c28aa3d46ab97ea08a82;p=thirdparty%2FChart.js.git Remove duplicate Scriptable definitions (#8223) --- diff --git a/types/index.esm.d.ts b/types/index.esm.d.ts index ec6e4f8ea..8745bee01 100644 --- a/types/index.esm.d.ts +++ b/types/index.esm.d.ts @@ -16,11 +16,31 @@ import { TimeUnit } from "./adapters"; import { AnimationEvent } from './animation'; import { Element }from './element'; import { ChartArea, Point } from './geometric'; +import { + Scriptable, + ScriptableOptions, + ScriptableAndArrayOptions +} from './scriptable'; export { DateAdapterBase, DateAdapter, TimeUnit, _adapters } from './adapters'; export { Animation, Animations, Animator, AnimationEvent } from './animation'; export { Element } from './element'; export { ChartArea, Point } from './geometric'; +export { + Scriptable, + ScriptableOptions, + ScriptableAndArray, + ScriptableAndArrayOptions +} from './scriptable'; + +export interface ScriptableContext { + chart: Chart; + dataPoint: any; + dataIndex: number; + dataset: ChartDataset; + datasetIndex: number; + active: boolean; +} export interface ParsingOptions { /** @@ -60,8 +80,8 @@ export interface ControllerDatasetOptions extends ParsingOptions { export interface BarControllerDatasetOptions extends ControllerDatasetOptions, - ScriptableAndArrayOptions, - ScriptableAndArrayOptions { + ScriptableAndArrayOptions, + ScriptableAndArrayOptions { /** * The base axis of the dataset. 'x' for vertical bars and 'y' for horizontal bars. * @default 'x' @@ -118,8 +138,8 @@ export const BarController: ChartComponent & { export interface BubbleControllerDatasetOptions extends ControllerDatasetOptions, - ScriptableAndArrayOptions, - ScriptableAndArrayOptions {} + ScriptableAndArrayOptions, + ScriptableAndArrayOptions {} export interface BubbleDataPoint { /** @@ -146,10 +166,10 @@ export const BubbleController: ChartComponent & { export interface LineControllerDatasetOptions extends ControllerDatasetOptions, - ScriptableAndArrayOptions, - ScriptableAndArrayOptions, - ScriptableOptions, - ScriptableOptions { + ScriptableAndArrayOptions, + ScriptableAndArrayOptions, + ScriptableOptions, + ScriptableOptions { /** * The ID of the x axis to plot this dataset on. */ @@ -204,8 +224,8 @@ export const ScatterController: ChartComponent & { export interface DoughnutControllerDatasetOptions extends ControllerDatasetOptions, - ScriptableAndArrayOptions, - ScriptableAndArrayOptions { + ScriptableAndArrayOptions, + ScriptableAndArrayOptions { /** * Sweep to allow arcs to cover. @@ -322,10 +342,10 @@ export const PolarAreaController: ChartComponent & { export interface RadarControllerDatasetOptions extends ControllerDatasetOptions, - ScriptableOptions, - ScriptableOptions, - ScriptableOptions, - ScriptableOptions { + ScriptableOptions, + ScriptableOptions, + ScriptableOptions, + ScriptableOptions { /** * The ID of the x axis to plot this dataset on. */ @@ -1268,15 +1288,13 @@ export const Scale: { new (cfg: any): Scale; }; -export interface ScriptAbleScaleContext { +export interface ScriptableScaleContext { chart: Chart; scale: Scale; index: number; tick: Tick; } -export type ScriptAbleScale = T | ((ctx: ScriptAbleScaleContext) => T); - export const Ticks: { formatters: { /** @@ -1345,21 +1363,6 @@ export interface ChartComponent { afterUnregister?(): void; } - -export interface ScriptableContext { - chart: Chart; - dataPoint: any; - dataIndex: number; - dataset: ChartDataset; - datasetIndex: number; - active: boolean; -} - -export type Scriptable = T | ((ctx: ScriptableContext) => T); -export type ScriptableOptions = { [P in keyof T]: Scriptable }; -export type ScriptableAndArray = readonly T[] | Scriptable; -export type ScriptableAndArrayOptions = { [P in keyof T]: ScriptableAndArray }; - export interface CoreInteractionOptions { /** * Sets which elements appear in the tooltip. See Interaction Modes for details. @@ -1386,10 +1389,10 @@ export interface HoverInteractionOptions extends CoreInteractionOptions { } export interface CoreChartOptions extends ParsingOptions { - animation: Scriptable; + animation: Scriptable; datasets: { - animation: Scriptable; + animation: Scriptable; }; /** @@ -1467,7 +1470,7 @@ export interface CoreChartOptions extends ParsingOptions { onClick(event: ChartEvent, elements: ActiveElement[], chart: Chart): void; layout: { - padding: Scriptable; + padding: Scriptable; }; plugins: PluginOptions; @@ -2488,7 +2491,7 @@ export interface TooltipOptions extends CoreInteractionOptions { */ textDirection: string; - animation: Scriptable; + animation: Scriptable; callbacks: TooltipCallbacks; } @@ -2555,7 +2558,7 @@ export interface GridLineOptions { /** * @default 'rgba(0, 0, 0, 0.1)' */ - color: ScriptAbleScale | readonly Color[]; + color: Scriptable | readonly Color[]; /** * @default [] */ @@ -2563,11 +2566,11 @@ export interface GridLineOptions { /** * @default 0 */ - borderDashOffset: ScriptAbleScale; + borderDashOffset: Scriptable; /** * @default 1 */ - lineWidth: ScriptAbleScale | readonly number[]; + lineWidth: Scriptable | readonly number[]; /** * @default true @@ -2588,11 +2591,11 @@ export interface GridLineOptions { /** * @default 0 */ - tickBorderDashOffset: ScriptAbleScale; + tickBorderDashOffset: Scriptable; /** * @default 'rgba(0, 0, 0, 0.1)' */ - tickColor: ScriptAbleScale | readonly Color[]; + tickColor: Scriptable | readonly Color[]; /** * @default 10 */ @@ -2621,11 +2624,11 @@ export interface TickOptions { * Color of tick * @see Defaults.color */ - color: ScriptAbleScale; + color: Scriptable; /** * see Fonts */ - font: ScriptAbleScale; + font: Scriptable; /** * Sets the offset of the tick labels from the axis */ @@ -2954,22 +2957,22 @@ export type RadialLinearScaleOptions = CoreScaleOptions & { * Color of angled lines. * @default 'rgba(0, 0, 0, 0.1)' */ - color: ScriptAbleScale; + color: Scriptable; /** * Width of angled lines. * @default 1 */ - lineWidth: ScriptAbleScale; + lineWidth: Scriptable; /** * Length and spacing of dashes on angled lines. See MDN. * @default [] */ - borderDash: ScriptAbleScale; + borderDash: Scriptable; /** * Offset for line dashes. See MDN. * @default 0 */ - borderDashOffset: ScriptAbleScale; + borderDashOffset: Scriptable; }; /** @@ -2999,11 +3002,11 @@ export type RadialLinearScaleOptions = CoreScaleOptions & { * Color of label * @see Defaults.color */ - color: ScriptAbleScale; + color: Scriptable; /** * @see https://www.chartjs.org/docs/next/axes/general/fonts.md */ - font: ScriptAbleScale; + font: Scriptable; /** * Callback function to transform data labels to point labels. The default implementation simply returns the current string. @@ -3026,7 +3029,7 @@ export type RadialLinearScaleOptions = CoreScaleOptions & { * Color of label backdrops. * @default 'rgba(255, 255, 255, 0.75)' */ - backdropColor: ScriptAbleScale; + backdropColor: Scriptable; /** * Horizontal padding of label backdrop. * @default 2 @@ -3063,7 +3066,7 @@ export type RadialLinearScaleOptions = CoreScaleOptions & { * If true, draw a background behind the tick labels. * @default true */ - showLabelBackdrop: ScriptAbleScale; + showLabelBackdrop: Scriptable; }; }; diff --git a/types/scriptable.d.ts b/types/scriptable.d.ts new file mode 100644 index 000000000..d85d01270 --- /dev/null +++ b/types/scriptable.d.ts @@ -0,0 +1,4 @@ +export type Scriptable = T | ((ctx: TContext) => T); +export type ScriptableOptions = { [P in keyof T]: Scriptable }; +export type ScriptableAndArray = readonly T[] | Scriptable; +export type ScriptableAndArrayOptions = { [P in keyof T]: ScriptableAndArray };