Reputation: 77
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/
Upvotes: 0
Views: 1244
Reputation: 37588
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:
Upvotes: 2
Reputation: 6974
EDIT In fiddle that I found, there is a prototype like this.
$(function () {
//buttons
(function (H) {
//rangeSelector buttons
var A = H.Chart;
var options = H.getOptions();
p = H.extend;
k = H.merge;
p(A.prototype, {
bindEvents: function (b, c) {
if (c.click) {
b.on("click", c.click);
}
}
});
//rangeSelector events
A.prototype.callbacks.push(function (b) {
//
var c = b.rangeSelector.buttons, d = b.options.rangeSelector;
if (c && d) {
for (var i = 0; i < c.length; i++) {
b.bindEvents(c[i], d);
}
}
});
})(Highcharts);
Try use this
rangeSelector: {
click: function () {
alert("test");
},
buttons: [{
type: 'year',
count: 5,
text: '5y',
click: function () {
alert("test");
}
}
}
I found in this fiddle http://jsfiddle.net/stepday/LSdrX/ I haven't tested in my local, but you can try with example code in fiddle
Upvotes: -1