Maëlig
Maëlig

Reputation: 409

Highcharts : set a maximum number of ticks with a fixed interval

I would like to be set a fixed interval of 2 hours between every tick on the X axis, but also limit the number of ticks on the whole axis to 5, cropping out the extra data if necessary. Currently I can achieve one or the other, but not both, using the following config :

tickInterval: 2 * 3600 * 1000 // sets the interval between each tick to 2 hours


tickPixelInterval: 100 // sets the number max number of ticks (for the current graph width) to 5

JSFiddle here

Is there a way to achieve both ?

Upvotes: 1

Views: 3415

Answers (1)

pawel_d
pawel_d

Reputation: 3070

You can set desired range using max or maxPadding properties.

API Reference:
http://api.highcharts.com/highcharts/xAxis.max
http://api.highcharts.com/highcharts/xAxis.maxPadding

Examples:
https://jsfiddle.net/vwrpwcq0/ - setting max
https://jsfiddle.net/ztqL9j3g/ - setting maxPadding

Upvotes: 1

Related Questions