Change range in Highstock dynamically

I want to change the range in a chart dynamically. If I go from a big value to a smaller, everything works fine. But if I want to go to the bigger again, nothing happens.

You can try this here: http://jsfiddle.net/Charissima/wkBwW/15/

Click the button 'Range 50' and afterwords 'Range 20'. Then 'Range 50' again. You can see the color changing but not the range.

I tried hard to figure out how to fix this problem, but without success. I hope, somebody 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() {
            // generate an array of random data
            var data = [], i;
            for( i = 1; i <= 100; i++) {
                data.push([
                    i,
                    Math.round(Math.random() * 100)
                ]);
            }
            return data;
        })()
    }]

});

// the button action
$('#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
    });     
  });        
});

Answers:

Answer

Have you tried to use setExtremes() http://api.highcharts.com/highstock#xAxis.events.setExtremes which allow to define range.

EDIT: Example: http://jsfiddle.net/wkBwW/16/

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us Javascript

©2020 All rights reserved.