Force morris to use only integer values on Y axis

New option gridIntegers was added to force morris to use only integer numbers on the grid (Y axis). gridIntegers accepts a boolean value (false=default). When set to true, morris will use only integer values on the Y axis.
This commit is contained in:
t3chn0r 2013-12-23 19:31:32 -05:00
parent 7bce55890f
commit 0fd5a542d6

View File

@ -101,6 +101,7 @@ class Morris.Grid extends Morris.EventEmitter
gridTextSize: 12
gridTextFamily: 'sans-serif'
gridTextWeight: 'normal'
gridIntegers: false
hideHover: false
yLabelFormat: null
xLabelAngle: 0
@ -221,6 +222,10 @@ class Morris.Grid extends Morris.EventEmitter
@ymax = Math.max(@ymax, @grid[@grid.length - 1])
else
step = (@ymax - @ymin) / (@options.numLines - 1)
if @options.gridIntegers is true
step = Math.min(1, Math.round(step))
@grid = (y for y in [@ymin..@ymax] by step)
@dirty = true