how I can set the xAxis maxRange(minRange) for each rangeSelector button separately?
For example: When I click on rangeSelector button "Day bars", I would like to set xAxis extremes for zoom in to 10days(so 10days or 10bars will be the minim for zoom in, which will be show in plot area) and for zoom out to 60days(60days or 60bars will be maximum for zoom out, which will be show in plot area). When I click on rangeSelector button with "Week bars", I would like to set xAxis extremes for zoom in to 10weeks(so 10weeks or 10bars will be the minim for zoom in, which will be show in plot area) and for zoom out to 60weeks(60weeks or 60bars will be maximum for zoom out, which will be show in plot area).
Could I use somehow maxRange,minRange functions in rangeSelector? Could I set in chart event, rangeSelector event or xAxis event? I tried to set it through xAxis afterSetExtremes event, but is not working.
xAxis: {
type: 'datetime',
events: {
afterSetExtremes:
function(e)
{
if (e.trigger == "rangeSelectorButton" && e.rangeSelectorButton.text == "Day")
{
console.log("day");
var maxDistance = 1 * 30 * 24 * 3600 * 1000; //1 months time
var xaxis = this;
if ((e.max - e.min) > maxDistance) {
var min = e.max - maxDistance;
var max = e.max;
window.setTimeout(function() {
xaxis.setExtremes(min, max);
}, 1);
}
}
if (e.trigger == "rangeSelectorButton" && e.rangeSelectorButton.text == "Week")
{
console.log("Week");
var maxDistance = 12 * 30 * 24 * 3600 * 1000; //12 months time
var xaxis = this;
if ((e.max - e.min) > maxDistance) {
var min = e.max - maxDistance;
var max = e.max;
window.setTimeout(function() {
xaxis.setExtremes(min, max);
}, 1);
}
}
},
}
}
Please see jsFiddle: https://jsfiddle.net/PaulJaker/mrgk5s19/120/
Thank you a lot.
Paul