Reputation: 309
Does anyone know how to programmatically update the dates in the rangeSelector?
Here is a fiddle of my chart http://jsfiddle.net/ibike365/jneQh/1/
$.getJSON('http://www.highcharts.com/samples/data/jsonp.php?filename=aapl-c.json&callback=?', function(data) {
// Create the chart
window.chart = new Highcharts.StockChart({
chart : {
renderTo : 'container'
},
rangeSelector : {
selected : 1
},
title : {
text : 'AAPL Stock Price'
},
series : [{
name : 'AAPL',
data : data,
tooltip: {
valueDecimals: 2
}
}]
},function(chart){
console.log(chart.rangeSelector);
});
});
I have a use case where I need to be able to set specific start and end dates for the selected range when I load the chart, but I'm not having much luck. When I inspect the chart.rangeSelector property in the console, I don't even see what to update.
Thanks for any help!
Upvotes: 1
Views: 1531
Reputation: 309
I figured it out:
chart.xAxis[0].setExtremes(startDate.getTime(), endDate.getTime());
Upvotes: 3