3
votes

I have a highcharts graph where the X axis units is date. My data is rounded to the nearest day, so there is no point zooming in beyond the day level.

However, highcharts lets me zoom in to the hour level. I don't want to let users zoom in any deeper than days. So, I have defined my X axis as:

 xAxis: {
        type: 'datetime',
        dateTimeLabelFormats: { // don't display the dummy year
            month: '%b \'%y',
            year: '%Y'               
        },
        minRange: 86400000                              
    },

yet I can still zoom in to the hour level. I set minRange to 86400000 (i.e. 1 day) but it has no effect. Am I setting the wrong thing?

1
You are using highcharts or highstock? If so, are you talking about the zoom buttons having a 1 hour option? Or are you talking about the navigation window (small graph at bottom) zooming?Jugal Thakkar
It is possible to reproduce it in jsfiddle.net? Because minRange limit how "deep" you zoom, so all should work properly.Sebastian Bochan
I am using highstock (just switched) - same issue. It appears that the minrange limits how much time/date can fit on the screen (limit zoom based on screen realestate), not limit based on time resolution. THat seems backwards, but appears to work that way. Is this correct/as designed?TSG
Just like described in docs. In short: minRange = smallest possible timeframe visible on axis. 1day in your case will mean after zooming, you will always get range: actual_max_zoom - actual_min_zoom >= minRange.Paweł Fus

1 Answers

0
votes

Maybe too late, but for other people may be useful:

For me this was my solution:

maxZoom: 14 * 24 * 3600000

this means 14 days as max zoom, so no hours will be displayed