I want to dynamically change the range in the chart. If I go from a large value to a smaller one, everything works fine. But if I want to go back to more, nothing will happen.
You can try this here: http://jsfiddle.net/Charissima/wkBwW/15/
Press the "Range 50" button and the password "Range 20". Then "Range 50" again. You can see the color change, but not the range.
I tried to figure out how to solve this problem, but to no avail. Hope someone can help me.
<div id="container" style="height: 400px; min-width: 600px"></div>
<script src="http://code.highcharts.com/stock/highstock.js"></script>
<button id="button_20">Range 20</button>
<button id="button_50">Range 50</button>
$(function() {
$('#container').highcharts({
chart: {
},
rangeSelector: {
enabled: false
},
exporting: {
enabled: false
},
title : {
text : 'Ranges'
},
navigator: {
enabled: true,
},
xAxis: {
lineColor: '#ffcc00'
},
series : [{
name : 'Random data',
data : (function() {
var data = [], i;
for( i = 1; i <= 100; i++) {
data.push([
i,
Math.round(Math.random() * 100)
]);
}
return data;
})()
}]
});
$('#button_20').click(function() {
var chart = $('#container').highcharts();
chart.xAxis[0].update({
lineColor: '#00ff00',
range: 20
});
});
$('#button_50').click(function() {
var chart = $('#container').highcharts();
chart.xAxis[0].update({
lineColor: '#E22636',
range: 50
});
});
});
source
share