johnyg07
Posts: 6
Joined: Tue Aug 24, 2021 9:01 pm

default range selection for 6m on load

Hi, for stock chart, how can I have the chart to display default 6m of data on load. the data set has data for more than couple of years but on load, I only want it to display 6m of data. I tried various combination of rangeSelector.selected option with buttons but that does not seem to be working.
any help in matter is greatly appreciated.
mateusz.b
Posts: 2006
Joined: Tue Jul 13, 2021 11:34 am

Re: default range selection for 6m on load

Hello johnyg07,

Thanks for contacting us with your question.

You're almost right. To achieve such result indeed we need to change the initial date range on load, but with setExtremes() method. You have to pass as arguments new min and new max value. In your case it will be a start date and an end date.
Demo: https://jsfiddle.net/BlackLabel/8dan251h/
API reference: https://api.highcharts.com/class-refere ... etExtremes

Let me know if that was what you were looking for!
Best regards!
Mateusz Bernacik
Highcharts Developer
johnyg07
Posts: 6
Joined: Tue Aug 24, 2021 9:01 pm

Re: default range selection for 6m on load

worked like charm! thank you !
mateusz.b
Posts: 2006
Joined: Tue Jul 13, 2021 11:34 am

Re: default range selection for 6m on load

You're welcome! In case of any further questions, feel free to contact us again.
Mateusz Bernacik
Highcharts Developer

Return to “Highcharts Stock”