I want to show some custom data in my candlestick type of HighChart tooltip. How should I do that?
I've found some solutions for other types of charts but they didn't work for me.
As you know, we have access to value of X, high, low, close and open as default. But I want to embed for example "Name" or "Percent" values to each points to show on tooltip.
I'll appreciate if anyone could answer my question.
Regards.
Yes you can definitely do that. You can access the all the data you pass to the highcharts.
lets say here is a the sample structure of the data you are plotting.
{
low: 19,
high: 30,
open: 20,
close: 28,
pram2: 'hi',
param1: 'hello'
}
as you already know the default parameters here are open, close, low and high respectively. we want to show 2 more prams called param1 and pram2 in the tooltip. for that we need to have them in the as shown below.
how to access these params from tooltip?
it is quite simple. These is a prameter called formatter in tooltip.
tooltip : {
formatter: function() {
........
........
........
return something
}
}
this formatter function gets called every tie your mouse goes on to a data point on the plot.
in this formatter function you can access the data of that point as this.point
. here our additional params can be accessed as this.point.param1
and this.point.pram2
here is a jsfiddle that will help you.