Merge branch 'feature/coffee_idioms' of https://github.com/sudodoki/morris.js into sudodoki-feature/coffee_idioms

Conflicts:
	lib/morris.grid.coffee
This commit is contained in:
Olly Smith 2013-11-09 17:50:53 +00:00
commit 6422b543be
4 changed files with 9 additions and 11 deletions

View File

@ -29,7 +29,7 @@ class Morris.Area extends Morris.Line
else else
total += (y || 0) total += (y || 0)
@transY(total) @transY(total)
row._ymax = Math.max.apply Math, row._y row._ymax = Math.max row._y...
# draw the data series # draw the data series
# #

View File

@ -29,16 +29,14 @@ class Morris.Donut extends Morris.EventEmitter
# Create and render a donut chart. # Create and render a donut chart.
# #
constructor: (options) -> constructor: (options) ->
if not (this instanceof Morris.Donut) return new Morris.Donut(options) unless (@ instanceof Morris.Donut)
return new Morris.Donut(options) @options = $.extend {}, @defaults, options
if typeof options.element is 'string' if typeof options.element is 'string'
@el = $ document.getElementById(options.element) @el = $ document.getElementById(options.element)
else else
@el = $ options.element @el = $ options.element
@options = $.extend {}, @defaults, options
if @el == null || @el.length == 0 if @el == null || @el.length == 0
throw new Error("Graph placeholder not found.") throw new Error("Graph placeholder not found.")
@ -88,7 +86,7 @@ class Morris.Donut extends Morris.EventEmitter
@text1 = @drawEmptyDonutLabel(cx, cy - 10, @options.labelColor, 15, 800) @text1 = @drawEmptyDonutLabel(cx, cy - 10, @options.labelColor, 15, 800)
@text2 = @drawEmptyDonutLabel(cx, cy + 10, @options.labelColor, 14) @text2 = @drawEmptyDonutLabel(cx, cy + 10, @options.labelColor, 14)
max_value = Math.max.apply(null, value for value in @values) max_value = Math.max @values...
idx = 0 idx = 0
for value in @values for value in @values
if value == max_value if value == max_value

View File

@ -139,8 +139,8 @@ class Morris.Grid extends Morris.EventEmitter
ymin = if @cumulative then 0 else null ymin = if @cumulative then 0 else null
if @options.goals.length > 0 if @options.goals.length > 0
minGoal = Math.min.apply(null, @options.goals) minGoal = Math.min @options.goals...
maxGoal = Math.max.apply(null, @options.goals) maxGoal = Math.max @options.goals...
ymin = if ymin? then Math.min(ymin, minGoal) else minGoal ymin = if ymin? then Math.min(ymin, minGoal) else minGoal
ymax = if ymax? then Math.max(ymax, maxGoal) else maxGoal ymax = if ymax? then Math.max(ymax, maxGoal) else maxGoal
@ -191,8 +191,8 @@ class Morris.Grid extends Morris.EventEmitter
@events = (Morris.parseDate(e) for e in @options.events) @events = (Morris.parseDate(e) for e in @options.events)
else else
@events = @options.events @events = @options.events
@xmax = Math.max(@xmax, Math.max.apply(null, @events)) @xmax = Math.max(@xmax, Math.max(@events...))
@xmin = Math.min(@xmin, Math.min.apply(null, @events)) @xmin = Math.min(@xmin, Math.min(@events...))
if @xmin is @xmax if @xmin is @xmax
@xmin -= 1 @xmin -= 1

View File

@ -52,7 +52,7 @@ class Morris.Line extends Morris.Grid
row._x = @transX(row.x) row._x = @transX(row.x)
row._y = for y in row.y row._y = for y in row.y
if y? then @transY(y) else y if y? then @transY(y) else y
row._ymax = Math.min.apply(null, [@bottom].concat(y for y in row._y when y?)) row._ymax = Math.min [@bottom].concat(y for y in row._y when y?)...
# hit test - returns the index of the row at the given x-coordinate # hit test - returns the index of the row at the given x-coordinate
# #