From f89eb54b5819412cc0ce0bcc2aadaa980d1817ca Mon Sep 17 00:00:00 2001 From: Daniel Luz Date: Mon, 15 Oct 2018 13:28:27 -0300 Subject: [PATCH] Declare enum values where applicable (#29722) --- types/chart.js/chart.js-tests.ts | 2 ++ types/chart.js/index.d.ts | 16 +++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/types/chart.js/chart.js-tests.ts b/types/chart.js/chart.js-tests.ts index 41ab453e0f..6283bd4d94 100644 --- a/types/chart.js/chart.js-tests.ts +++ b/types/chart.js/chart.js-tests.ts @@ -36,6 +36,7 @@ const chart: Chart = new Chart(new CanvasRenderingContext2D(), { tooltips: { filter: data => Number(data.yLabel) > 0, intersect: true, + mode: 'index', itemSort: (a, b) => Math.random() - 0.5, position: "average", caretPadding: 2, @@ -125,6 +126,7 @@ const chartConfig: Chart.ChartConfiguration = { backgroundColor: '#37738353', borderColor: '#37738353', borderWidth: 3, + borderCapStyle: 'round', fill: true }] }, diff --git a/types/chart.js/index.d.ts b/types/chart.js/index.d.ts index f779cdc57d..689583d8d9 100644 --- a/types/chart.js/index.d.ts +++ b/types/chart.js/index.d.ts @@ -174,6 +174,8 @@ declare namespace Chart { type PositionType = 'left' | 'right' | 'top' | 'bottom'; + type InteractionMode = 'point' | 'nearest' | 'single' | 'label' | 'index' | 'x-axis' | 'dataset' | 'x' | 'y'; + interface ChartArea { top: number; right: number; @@ -185,10 +187,10 @@ declare namespace Chart { text?: string; fillStyle?: string; hidden?: boolean; - lineCap?: string; + lineCap?: 'butt' | 'round' | 'square'; lineDash?: number[]; lineDashOffset?: number; - lineJoin?: string; + lineJoin?: 'bevel' | 'round' | 'miter'; lineWidth?: number; strokeStyle?: string; pointStyle?: PointStyle; @@ -331,7 +333,7 @@ declare namespace Chart { interface ChartTooltipOptions { enabled?: boolean; custom?(a: any): void; - mode?: string; + mode?: InteractionMode; intersect?: boolean; backgroundColor?: ChartColor; titleFontFamily?: string; @@ -373,7 +375,7 @@ declare namespace Chart { type ChartTooltipPositioner = (elements: any[], eventPosition: Point) => Point; interface ChartHoverOptions { - mode?: string; + mode?: InteractionMode; animationDuration?: number; intersect?: boolean; onHover?(this: Chart, event: MouseEvent, activeElements: Array<{}>): any; @@ -541,10 +543,10 @@ declare namespace Chart { backgroundColor?: ChartColor | ChartColor[]; borderWidth?: number | number[]; borderColor?: ChartColor | ChartColor[]; - borderCapStyle?: string; + borderCapStyle?: 'butt' | 'round' | 'square'; borderDash?: number[]; borderDashOffset?: number; - borderJoinStyle?: string; + borderJoinStyle?: 'bevel' | 'round' | 'miter'; borderSkipped?: PositionType; data?: number[] | ChartPoint[]; fill?: boolean | number | string; @@ -566,7 +568,7 @@ declare namespace Chart { pointStyle?: PointStyle | HTMLImageElement | HTMLCanvasElement | Array; xAxisID?: string; yAxisID?: string; - type?: string; + type?: ChartType | string; hidden?: boolean; hideInLegendAndTooltip?: boolean; showLine?: boolean;