mirror of
https://github.com/morrisjs/morris.js.git
synced 2024-11-10 21:36:34 +01:00
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:
parent
7bce55890f
commit
0fd5a542d6
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user