score:7

Accepted answer

instead of using .rangeselector({settings}), use the .clickbutton function:

chart.rangeselector.clickbutton(0,{type: 'month', count: 1},true);

however, this function seems to be somewhat strange and undocumented from what i can tell.

it accepts the following arguments:

* @param {number} i the index of the button
* @param {object} rangeoptions
* @param {boolean} redraw

redraw defaults to true, and i will just visually select one of the buttons (other than that, it seems to do nothing). the bread and butter seems to be in the rangeoptions, which is an object with a type and count. for instance, in the example above, it selects the most recent 1 month. other available options are:

* millisecond
* second
* minute
* hour
* day
* week
* month
* ytd
* year
* all

however, please note that you cannot .destroy(); the range selector and have this still work, you would possibly have to do a little bit of hacking to get that to work.

here is a jsfiddle illustrating it: http://jsfiddle.net/hfpr2/

score:0

in case when you destroy rangeseletor object, it is not possible to display object which doens't exist. so if you woudl like to display rangeselector only what you need is enable it by http://api.highcharts.com/highstock#rangeselector.enabled.

score:0

to use the clickbutton() you need to call it like this...

chart.rangeselector.clickbutton(0, chart.rangeselector.buttonoptions[0], true);

where the buttonoptions[] item matches the first parameter.

score:1

you don't have to give the rangeselector the options to use. you can simply call:

chart.rangeselector.clickbutton(0, true);

thus the first button will be clicked while using its current options.


Related Query

More Query from same tag