First, I have several charts on my page - To make it more easy to compare data within the different charts, I'm setting the maximum yAxis to the highest one that is available.
Question: How do I revert the maximum I've just set without refetching the data? I'm looking for something like "autoscale" as it works if I add a maximum value of 11245, the maximum yAxis is something like 12500. I would like to restore all my charts.
Demo: http://jsfiddle.net/wiesson/0p4z1mfj
$('#setMax').click(function (ev) {
var yAxisMax = 0;
$('[data-chart]').each(function (item) {
var c = $(this).highcharts();
if (c.yAxis[0].max > yAxisMax) {
yAxisMax = c.yAxis[0].max;
}
});
$('[data-chart]').each(function (item) {
c = $(this).highcharts();
if (c.yAxis[0].max < yAxisMax) {
c.yAxis[0].update({
max: yAxisMax
});
}
});
});
You can simply remove extremes from axis. In general, I would suggest using axis.setExtremes(min, max)
instead of axis.update(options)
. setExtremes
should have much better performance in compare to update
.
Code:
$('#setDefault').click(function (ev) {
$('[data-chart]').each(function (item) {
$(this).highcharts().yAxis[0].setExtremes(null, null);
});
});
And demo: http://jsfiddle.net/0p4z1mfj/9/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With