John Fred John Fred - 3 months ago 16
jQuery Question

Highstock Trigger javascript when range selector button clicked

How would I get, say, an

alert("Don't touch me!")
to execute when I press the '2Week' button in the following fiddle: https://jsfiddle.net/610335vt/

Answer

You can catch the setExtremes event, check e.rangeSelectorButton.text and find a current button. Then call custom action.

   xAxis: {
     events: {
       setExtremes: function(e) {
        if (e.rangeSelectorButton.text === "2Weeks") {
           alert('a');
         }
       }
     }
   },

Example: