GeorgeBT
Posts: 4
Joined: Tue Dec 04, 2018 10:31 am

Customising tooltip

Tue Dec 04, 2018 1:30 pm

Good afternoon,

I’m using highcharts for a project and was wondering if anyone could help with a few small queries.

I have this example chart here: https://codepen.io/GeorgeBT/pen/pQYXyw?editors=1111 to illustrate what I would like.

I want to add a few bits of information to the tooltip on my chart.

Firstly, I would like to get the total number of chunks in the stacked bar. So in my example there’s 3 different chunks, so I would like the tooltip to say total chunks: 3
Secondly, I would like to get the chunks position in the stack. So, if the user hovers over the first chunk it will be position 1.
Thirdly, I would like to be able to get the average of the data in the tooltip - I suppose this would just be dividing the total (Which I have) by the number of chunks in the stack.

If anybody could help on these queries I would be greatly appreciated!

Many thanks,
George

bastss
Posts: 140
Joined: Wed Oct 17, 2018 10:59 am

Tue Dec 04, 2018 2:23 pm

Hey George!

You're welcome - DEMO: https://jsfiddle.net/Bastss/h9rgyL6z/. I've added id for point to get his position. API: https://api.highcharts.com/highcharts/s ... ar.data.id.

Best regards!

GeorgeBT
Posts: 4
Joined: Tue Dec 04, 2018 10:31 am

Re: Customising tooltip

Tue Dec 04, 2018 2:35 pm

Thank you! Exactly what I need your the best

GeorgeBT
Posts: 4
Joined: Tue Dec 04, 2018 10:31 am

Re: Customising tooltip

Tue Dec 04, 2018 4:09 pm

Can I ask though - Is it possible to achieve the position in the stack without setting IDs?

bastss
Posts: 140
Joined: Wed Oct 17, 2018 10:59 am

Re: Customising tooltip

Tue Dec 04, 2018 4:31 pm

Yes, it is possible - this will be series.index but we have to add 1 because counting starts from 0. Check example: https://jsfiddle.net/Bastss/4pjsky8q/.

Kind regards!

GeorgeBT
Posts: 4
Joined: Tue Dec 04, 2018 10:31 am

Re: Customising tooltip

Tue Dec 04, 2018 4:41 pm

Fantastic! Thank you so much that's solved a massive headache ive been having!

bastss
Posts: 140
Joined: Wed Oct 17, 2018 10:59 am

Re: Customising tooltip

Tue Dec 04, 2018 4:52 pm

You're welcome :)

Return to “Highcharts Usage”