sbozzie
sbozzie

Reputation: 727

HighStock chart.rangeSelector after loading

I know how to set the default range selector when defining a new chart by using

rangeSelector: {
    selected:0,
},

Is it possible to change this after new data has been loaded though javascript?

eg:

chart.series[0].setData(new data);
somethinghere rangeselector selected = 2;

I can set it using the range extreme, but this doesn't highlight the button to show the user what date range is selected and it would ( I think) make for a cleaner way of setting the date.

Upvotes: 4

Views: 5640

Answers (2)

dthartman
dthartman

Reputation: 104

I had some issues with this answer. Looking at the source for the latest stable version of Highstock, here's the argument documentation for the clickButton signature,

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

My example here is for a custom button to display the last 12 hours.

var rangeOptions = {
    type: "hour",
    count: 12
};

chart.rangeSelector.clickButton(2,rangeOptions,true);

Notice, I didn't need to set the button state either.

Upvotes: 1

Sebastian Bochan
Sebastian Bochan

Reputation: 37578

It is possible by catching button event and add state.

http://jsfiddle.net/jGALb/

 chart.rangeSelector.buttons[4].setState(2);
 chart.rangeSelector.clickButton(4,4,true);

Upvotes: 7

Related Questions