Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add a tooltip to the x-axis labels in highcharts?

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

like image 594
maximumride Avatar asked Dec 16 '22 01:12

maximumride


2 Answers

In general Highcharts doesn't support tooltip on labels.

However you have two solutions:

  • use 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)
  • use some plugin (Tooltipsy etc.), like this: http://jsfiddle.net/gW4p6/196/
like image 153
Paweł Fus Avatar answered Feb 01 '23 23:02

Paweł Fus


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

like image 22
Strikers Avatar answered Feb 02 '23 00:02

Strikers