How to set a selection range for highstock

I use highstock. How to adjust the range for a chart? I used:

chart.rangeSelector({ selected: 5 });   *

but it didn’t work.

I know how to do this in the following example: http://jsfiddle.net/Pffxt/2/ but I create a chart once and then add a series. When I create a chart (for example, an example) and add a series, RangeSelector does not work. I think I need to use, like ***

Please help me! Thanks you

+5
source share
4 answers

Instead of using, .rangeSelector({settings})use the function .clickButton:

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

However, this function seems somewhat strange and undocumented from what I can say.

It takes the following arguments:

* @param {Number} i The index of the button
* @param {Object} rangeOptions
* @param {Boolean} redraw

redraw true, i ( , , ). , , Options, . , 1 . :

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

, .destroy(); , , , , .

JSFiddle, : http://jsfiddle.net/HFPr2/

+7

rangeSelector , . :

chart.rangeSelector.clickButton(0, true);

, .

+1

If you destroy the rangeseletor object, it is not possible to display an object that does not exist. Therefore, if you like to display a rangeselector, only what you need is to enable it http://api.highcharts.com/highstock#rangeSelector.enabled .

0
source

To use clickButton (), you need to call it like this:

chart.rangeSelector.clickButton(0, chart.rangeSelector.buttonOptions[0], true);

If the buttonOptions [] element matches the first parameter.

0
source

All Articles