简体   繁体   中英

Setting options.rangeSelector.selected to 0 does not set zoom to correct level in highstock

I am trying to change the default zoom level on a simple highstock chart. I've been looking around for a solution and came up with this:

rangeSelector: {
            selected:0,
        },

This did not work with the code below

   chart = new Highcharts.StockChart({
        chart: {
            renderTo: 'dummycontainer'
        },

        rangeSelector: {
            selected:0,
        },


        credits: {
            enabled: false
        },

        yAxis: {
            title: {
                text: ''
            },
            max: 100
        },

        tooltip: {
            pointFormat: '<span style="color:{series.color}">{series.name}</span>: <b>{point.y}</b> <br/>', //({point.change}%)
            valueDecimals: 2
        },
        series: [{
            name: 'MMP',
            data: [

            ],
            marker : {
                enabled : true,
                radius : 3
            },
            shadow : true
        }]
    });

What could be causing this?

rangeSelector: {
    selected:0
}

very much works

Change default time range | Highchart & Highstock @ jsFiddle

Check for any other javascript related errors in your browser's javascript console. If you are trying out on IE or even otherwise I would recommend removing the trailing comman( , ) from selected:0, like in the code above or the demo.

Trailing commas lead to invalid json and some browsers may not behave correctly with them. You can validate your json @ http://jsonlint.com/ or try the JSLint option in jsFiddle.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM