0

I have implemented the following code which allows user to click on y axis itself (value Axis, numeric axis) with using axisLabelClick event.

chart.bind("axisLabelClick", clickEvent);
chart.options.axisLabelClick = clickEvent; 


function clickEvent (e) {
   if (e.axis.type = "numeric")
       {
          if (!self.isClick)
            {
             self.isClick= true; 
            }
            else {
              self.isClick= false;
            }
      }
}

However I would like to know there is a way/trick or event to enable user to click y (value Axis, numeric Axis) axis title label (text) ?

casillas
  • 16,351
  • 19
  • 115
  • 215

1 Answers1

3

You could assign the axis title a specific property that you can then use in a jQuery selector. For example, set the color of the title to an rgba with an opacity of 0.9995 so that it is unlikely any other element will have exactly the same color:

valueAxis: {
    title: { 
        text: "y-axis label",
        color: "rgba(60,60,60, 0.9995)",                  
    },
},

Then setup your click handler:

$(document).on("click", '#chart text[fill="rgba(60,60,60, 0.9995)"]', function(){
            alert($(this).text());
});

DEMO

ezanker
  • 24,628
  • 1
  • 20
  • 35