Please refer to discussion Highcharts text labels for y-axis the way to setup y-axis label.
I used https://github.com/borisyankov/DefinitelyTyped/blob/master/highcharts/highcharts.d.ts in my TypeScript definition, but I could not find a way to define y-axis formatter.
Anybody ever tried before?
-- Update --
My origianl JavaScript code is
var yearChartOptions = {
yAxis: {
plotLines: [{
label: {
formatter: function () {
return '$' + Highcharts.numberFormat(this.value/1000, 0) +'k ';
}
},
}]
},
};
// Create the chart
var yearChart = new Highcharts.Chart(yearChartOptions);
In the code I have a this.value which is each bar (I used bar chart) value. In TypeScript (I have not changed to remove array yet).
var yearChartOptions: HighchartsOptions = {};
yearChartOptions.chart = {};
yearChartOptions.yAxis = [];
yearChartOptions.yAxis[0] = {};
yearChartOptions.yAxis[0].plotLines = {};
yearChartOptions.yAxis[0].plotLines.label = {};
yearChartOptions.yAxis[0].plotLines.label.style.formatter(() => "$" + Highcharts.numberFormat(this.value / 1000, 0) + "k ");
// Create the chart
var yearChart = new Highcharts.Chart(yearChartOptions);
The output is
/*
Compile Error.
See error list for details
D:/MyProject/Scripts/test.ts(36,56): The property 'formatter' does not exist on value of type 'HighchartsCSSObject'
D:/MyProject/Scripts/test.ts(36,107): The property 'value' does not exist on value of type 'Dashboard'
*/
And it won't compile.