Highstocks - How to change the default Zoom

倖福魔咒の 提交于 2019-11-29 11:06:21

问题


This question results from hours of googling highstocks, zoom, extremes, ranges, and every other possible variation of the words, all resulting in some variation of custom functions for high charts answers.

Is there a way to simply change the default zoom to 1 month instead of 3 months in HighStocks (not HighCharts) without writing a function to calculate what it happens to be?


回答1:


You can change it by the following code:

new Highcharts.StockChart({
    .
    .
    .
    rangeSelector: {
        selected: 0
    }
});

You can take a look the following example: http://jsfiddle.net/QnvrR/.

The default buttons are:

buttons: [{
    type: 'month',
    count: 1,
    text: '1m'
}, {
    type: 'month',
    count: 3,
    text: '3m'
}, {
    type: 'month',
    count: 6,
    text: '6m'
}, {
    type: 'ytd',
    text: 'YTD'
}, {
    type: 'year',
    count: 1,
    text: '1y'
}, {
    type: 'all',
    text: 'All'
}]

So, you have to change the number of the selected according to what you want.

Reference

  • http://api.highcharts.com/highstock#rangeSelector.buttons



回答2:


The zoom Links are index of an array, so if you want select the default render, set this params: rangeSelector: { selected: index_of_array }, in my case for select "all" have setted selected: 5



来源:https://stackoverflow.com/questions/11107752/highstocks-how-to-change-the-default-zoom

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!