How do I add a tooltip to the x-axis labels in highcharts?
xAxis: {
categories: ['Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas'],
labels: {
x: 5,
useHTML: true,
formatter: function () {
return categoryImgs[this.value];
}
}
}
Currently, tooltips are only shown on the points in the chart, I want the user to also see a tooltip/custom description when hovering on the labels on x-axis. Is that possible? Thanks
In general Highcharts doesn't support tooltip on labels.
However you have two solutions:
Custom-events
plugin, to add event on labels: https://www.highcharts.com/products/plugin-registry/single/15/Custom-Events (demo has click, mouse over should work the same to display custom tooltip)you can use formatter to make the label as a div. you can write your own jquery museOver event to it.
formatter: function(){
return "<div class='myClass'> " + this.value + "</div>"
}
I hope this will help you
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With