Skip to content

Commit

Permalink
Couple of quick fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
oesmith committed Nov 3, 2012
1 parent 0dc74db commit 8faced7
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
16 changes: 9 additions & 7 deletions lib/morris.grid.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,13 @@ class Morris.Grid extends Morris.EventEmitter
setData: (data, redraw = true) ->
ymax = if @cumulative then 0 else null
ymin = if @cumulative then 0 else null

if @options.goals.length > 0
ymax = Math.max(ymax, Math.max.apply(null,@options.goals))
ymin = Math.min(ymin, Math.min.apply(null,@options.goals))

minGoal = Math.min.apply(null, @options.goals)
maxGoal = Math.max.apply(null, @options.goals)
ymin = if ymin is null then minGoal else Math.min(ymin, minGoal)
ymax = if ymax is null then maxGoal else Math.max(ymax, maxGoal)

@data = $.map data, (row, index) =>
ret = {}
ret.label = row[@options.xkey]
Expand Down Expand Up @@ -118,9 +120,9 @@ class Morris.Grid extends Morris.EventEmitter

@events = []
if @options.parseTime and @options.events.length > 0
@events = $.map @options.events, (event, index) => Morris.parseDate(event)
@xmax = Math.max(@xmax, Math.max.apply(null,@events))
@xmin = Math.min(@xmin, Math.min.apply(null,@events))
@events = (Morris.parseDate(e) for e in @options.events)
@xmax = Math.max(@xmax, Math.max.apply(null, @events))
@xmin = Math.min(@xmin, Math.min.apply(null, @events))

if @xmin is @xmax
@xmin -= 1
Expand Down
21 changes: 15 additions & 6 deletions morris.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8faced7

Please sign in to comment.