Skip to content
Advertisement

How can I evenly distribute ticks when using maxTicksLimit?

I made a line chart using Chart.js version 2.1.3.

JavaScript

The output is as follow:

Screenshot

As you can see, I limited the maximum count of ticks to 8 via maxTicksLimit. However, the distribution is not even. How can I make the ticks distribute evenly?

p.s. there are always 289 records in the dataset, and the data is recorded every 5 minutes. Sample values of prices variable are:

JavaScript

I tried different values of maxTicksLimit, and the results are still not distributed evenly.

Advertisement

Answer

Chart.js uses an integral skipRatio (to figure out how many labels to skip). With Chart.js v2.1.x, you can write your own plugin to use a fractional skipRatio


Preview

enter image description here


Script

JavaScript

Fiddle – http://jsfiddle.net/bh63pe1v/

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement