Highcharts yAxis click event

馋奶兔 提交于 2021-02-11 13:37:05

问题


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


回答1:


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>`
        }

      }
    }
  }


来源:https://stackoverflow.com/questions/62939126/highcharts-yaxis-click-event

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!