From 0f7add13ba328dabad5af4f841417fce64a96213 Mon Sep 17 00:00:00 2001 From: arunksan Date: Wed, 20 Mar 2019 13:23:59 -0700 Subject: [PATCH] @types/highcharts: dataLabels support Highcharts.ganttChart() --- types/highcharts/index.d.ts | 47 ++++++++++++++++++++++------------ types/highcharts/test/index.ts | 43 +++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 16 deletions(-) diff --git a/types/highcharts/index.d.ts b/types/highcharts/index.d.ts index b3900154cd..8001ab7884 100644 --- a/types/highcharts/index.d.ts +++ b/types/highcharts/index.d.ts @@ -5,6 +5,7 @@ // Albert Ozimek // Juliƫn Hanssens // Johns Gresham +// ArunkeshavaReddy Sankaramaddi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -4458,7 +4459,10 @@ declare namespace Highcharts { * @default 'Solid' */ dashStyle?: string; - dataLabels?: DataLabels; + /** + * Gantt charts use one or more data labels for each series, for showing multiple date periods. + */ + dataLabels?: DataLabels | DataLabels[]; /** * Enable or disable the mouse tracking for a specific series. This includes point tooltips and click events on * graphs and points. For large datasets it improves performance. @@ -5984,6 +5988,7 @@ declare namespace Highcharts { interface ColumnRangeChartSeriesOptions extends IndividualSeriesOptions, ColumnRangeChart { } interface ErrorBarChartSeriesOptions extends IndividualSeriesOptions, ErrorBarChart { } interface FunnelChartSeriesOptions extends IndividualSeriesOptions, FunnelChart { } + interface GanttChartSeriesOptions extends IndividualSeriesOptions, SeriesChart { } interface GaugeChartSeriesOptions extends IndividualSeriesOptions, GaugeChart { } interface HeatMapSeriesOptions extends IndividualSeriesOptions, HeatMapChart { } interface LineChartSeriesOptions extends IndividualSeriesOptions, LineChart { } @@ -6023,11 +6028,11 @@ declare namespace Highcharts { * The id of a series in the drilldown.series array to use for a drilldown for this point. * @since 3.0.8 */ - drilldown?: string; - /** - * The end value of the point. For gantt datetime axes, the end value is the timestamp in milliseconds since 1970. - */ - end?: number; + drilldown?: string; + /** + * The end value of the point. For gantt datetime axes, the end value is the timestamp in milliseconds since 1970. + */ + end?: number; /** * Individual point events */ @@ -6106,11 +6111,11 @@ declare namespace Highcharts { * Whether to display a slice offset from the center. * @default false */ - sliced?: boolean; - /** - * The start value of the point. For gantt datetime axes, the start value is the timestamp in milliseconds since 1970. - */ - start?: number; + sliced?: boolean; + /** + * The start value of the point. For gantt datetime axes, the start value is the timestamp in milliseconds since 1970. + */ + start?: number; /** * The value of the point, resulting in a relative area of the point in the treemap. */ @@ -6686,6 +6691,16 @@ declare namespace Highcharts { yAxis?: AxisOptions[] | AxisOptions; } + /** + * The Gantt chart uses different plot options than the base Highcharts chart Options. + */ + interface GanttOptions extends Options { + /** + * The specific Gantt Series to append the GanttChart. + */ + series?: GanttChartSeriesOptions[]; + } + interface GlobalOptions extends Options { /** * Global options that don't apply to each chart. These options, like the lang options, must be set using the @@ -7269,11 +7284,11 @@ declare namespace Highcharts { * As Highcharts.Chart, but without need for the new keyword. * @since 4.2.0 */ - chart(renderTo: string | HTMLElement, options: Options, callback?: (chart: ChartObject) => void): ChartObject; - /** - * Highcharts ganttChart which doesn't require the new keyword. Required Highcharts Gantt module. - */ - ganttChart(renderTo: string | HTMLElement, options: Options, callback?: (chart: ChartObject) => void): ChartObject; + chart(renderTo: string | HTMLElement, options: Options, callback?: (chart: ChartObject) => void): ChartObject; + /** + * Highcharts ganttChart which doesn't require the new keyword. Required Highcharts Gantt module. + */ + ganttChart(renderTo: string | HTMLElement, options: GanttOptions, callback?: (chart: ChartObject) => void): ChartObject; /** * An array containing the current chart objects in the page. A chart's position in the array is preserved * throughout the page's lifetime. When a chart is destroyed, the array item becomes undefined. diff --git a/types/highcharts/test/index.ts b/types/highcharts/test/index.ts index 9ac03d1f81..358064b877 100644 --- a/types/highcharts/test/index.ts +++ b/types/highcharts/test/index.ts @@ -2886,3 +2886,46 @@ function test_GanttChart() { }], }); } + +// Tests DataLabels types for Highcharts.ganttChart, which uses the Gantt module +function test_GanttChartDataLabels() { + Highcharts.ganttChart('ganttChartContainer', { + xAxis: { + min: Date.UTC(2014, 9, 18), + max: Date.UTC(2014, 12, 20) + }, + series: [{ + name: 'Project 1', + data: [ + { + name: 'Lemon Tea', + start: Date.UTC(2014, 10, 18), + end: Date.UTC(2014, 11, 20) + }, + { + name: 'Stapler', + start: Date.UTC(2014, 11, 18), + end: Date.UTC(2014, 12, 20) + }, + { + name: 'Sierra', + start: Date.UTC(2014, 12, 18), + end: Date.UTC(2014, 12, 20) + }, + ], + dataLabels: [{ + enabled: true, + format: 'Data Label Left', + useHTML: true, + align: 'left', + allowOverlap: true, + }, { + enabled: true, + format: 'Data Label Right', + useHTML: true, + align: 'right', + allowOverlap: true, + }] + }], + }); +}