I have a chart with columnrange
type which should display some timelines. I have my time in UTC. It displays well on yAxis because of property ‘type: "datetime"
‘, but in tooltip it displays time in seconds. I want to format it.
I was trying to use constructions like this:
formatter() {
}
or like this:
formatter: function() {
}
but they are not allowed here and all I get is an error "'type' is declared here
"
The only available way to use formatter for me is:
formatter: (ctx) => {
}
Where ctx refers to Highcharts.tooltips
. But, arrow function does not allow me to get the y
value by using this
keyword. Please, tell me, what should I try?
2
Answers
I was trying different ways to use function() in order to access
this.y
and found the solution:All the ways works fine, I just need to pass context variable to function, either
formatter(ctx): {}
orformatter: function(ctx) {}
You can use the below notation with typed function parameters:
Live demo: https://stackblitz.com/edit/react-starter-typescript-ms2duw
API Reference: https://api.highcharts.com/class-reference/Highcharts#.TooltipFormatterCallbackFunction