I am curious to know why button 2 is not working in this example
In this jsfiddle example 'update' method attached to button 1 is working, but in my original code 'update' is also not working. It shows error: "object# has no method 'update'"
$(function () {
var options= {
chart: {
renderTo: 'container',
height: 400
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
series: [{
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
}]
};
var chart = new Highcharts.Chart(options);
buttonhandle1();
buttonhandle2()
});
function buttonhandle1(){
$("#b1").click(function(){
var chart = $('#container').highcharts();
chart.yAxis[0].update({
min:0,
max: 5,
tickInterval : 1,
});
});
}
function buttonhandle2(){
var chart = $('#container').highcharts();
$("#b2").click(function(){
chart.yAxis[0].min= 0;
chart.yAxis[0].max= 5;
chart.yAxis[0].tickInterval = 1;
chart.redraw();
});
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>
<div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
<button id="b1"> button 1</button>
<button id="b2"> button 2</button>
Because when you use chart.redraw()
you should also set isDirty
flag as true
http://jsfiddle.net/uKWQ9/3/
chart.yAxis[0].isDirty = true;
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