Troy Bryant
Troy Bryant

Reputation: 1024

Highcharts yAxis click event

I am using highcharts to render some data. On the yAxis I needed those values to be anchor tags and navigate to a side modal. Was able to get that working correctly by using the formatter function of the labels object. What I am trying to do now is the first cell of the table I want to disable the click events so it does not take the user to the side modal its display only.

labels{
 align: 'left',
 formatter: function(){
  return `<a href=javascript:openModal() ${this.value}  </a>`
 }
}

I've tried with jquery targeting the first table cell like

$('tspan.highcharts-anchor:first').unbind();

Any suggestions are greatly appreciated Thank you

Upvotes: 0

Views: 106

Answers (1)

Sebastian Wędzel
Sebastian Wędzel

Reputation: 11633

According to the comments - there is a code which disables opening the modal on the first yAxis.label.

Demo: https://jsfiddle.net/BlackLabel/25c38ez4/

  yAxis: {
    labels: {
      formatter: function() {
        console.log(this)
        if (this.isFirst) {
          return this.value
        } else {
          return `<a href=javascript:openModal()> ${this.value} </a>`
        }

      }
    }
  }

Upvotes: 0

Related Questions