问题
Minimum range of x-axis of data series is 5/15/2006 I send the current max value of x-axis of display chart is 5/24/2011 and zoom button is selected as past 7 days, then if I select the zoom button past 30 days, because it is out of the range of x-axis, so I want it to make this select invalid and keep the old past 7 days zoom button and the range of display chart doesn't change.
how to do this?
Here is the JS code:
var end = 1148428800000;
var rowcount;
$(function () {
$.getJSON('http://www.highcharts.com/samples/data/jsonp.php?filename=aapl-c.json&callback=?', function (data) {
// Create the chart
$('#container').highcharts('StockChart', {
navigator: {
enabled: false
},
scrollbar: {
enabled: false
},
rangeSelector: {
inputEnabled: false,
selected: 0,
buttonTheme: {
width: null
},
buttons: [{
type: 'day',
count: 6,
text: 'past 7 days'
}, {
type: 'day',
count: 14,
text: 'past 15 days'
}, {
type: 'day',
count: 29,
text: 'past 30 days'
}]
},
xAxis: {
max: end,
type: 'datetime',
minTickInterval: 24 * 3600 * 1000,
events: {
setExtremes: function (e) {
if (typeof (e.rangeSelectorButton) !== 'undefined') {
rowcount = e.rangeSelectorButton.count;
}
}
}
},
title: {
text: 'AAPL Stock Price'
},
series: [{
name: 'AAPL Stock Price',
data: data,
marker: {
enabled: true,
radius: 3
},
shadow: true,
tooltip: {
valueDecimals: 2
}
}]
});
});
});
Here is the [Jsfiddle]
来源:https://stackoverflow.com/questions/24573487/handle-rangeselector-button-when-it-is-out-of-range-of-xaxis-of-data-series