From 9a3fbe89bd7ff8a85605eba2ae4dd8540354e258 Mon Sep 17 00:00:00 2001 From: Nikita Grafov Date: Wed, 3 Jan 2018 22:29:25 +0300 Subject: [PATCH] [highcharts] Added type for axis labels formatter execution context (#22244) --- types/highcharts/index.d.ts | 8 +++++++- types/highcharts/test/index.ts | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/types/highcharts/index.d.ts b/types/highcharts/index.d.ts index cf13c8720e..3d01d66443 100644 --- a/types/highcharts/index.d.ts +++ b/types/highcharts/index.d.ts @@ -55,6 +55,12 @@ declare namespace Highcharts { max: number; } + interface AxisLabelFormatterOptions { + value: number; + isFirst: number; + isLast: number; + } + interface AxisLabels { /** * What part of the string the given position is anchored to. Can be one of 'left', 'center' or 'right'. Defaults to @@ -100,7 +106,7 @@ declare namespace Highcharts { * this are axis, chart, isFirst and isLast. * @default function() {return this.value;} */ - formatter?(): string; + formatter?(this: AxisLabelFormatterOptions): string; /** * Horizontal axis only. When staggerLines is not set, maxStaggerLines defines how many lines the axis is allowed to * add to automatically avoid overlapping X labels. Set to 1 to disable overlap detection. diff --git a/types/highcharts/test/index.ts b/types/highcharts/test/index.ts index 609ff56536..ad026a1e52 100644 --- a/types/highcharts/test/index.ts +++ b/types/highcharts/test/index.ts @@ -2247,7 +2247,7 @@ function test_AxisOptions() { distance: 10, enabled: true, format: "format", - formatter() { return this.value; }, + formatter() { return String(this.value); }, maxStaggerLines: 5, overflow: false, padding: 10,