mirror of
https://github.com/morrisjs/morris.js.git
synced 2024-11-10 21:36:34 +01:00
some coffee idioms, common constructor change
This commit is contained in:
parent
a738317adb
commit
9162df9f62
@ -29,7 +29,7 @@ class Morris.Area extends Morris.Line
|
||||
else
|
||||
total += (y || 0)
|
||||
@transY(total)
|
||||
row._ymax = Math.max.apply Math, row._y
|
||||
row._ymax = Math.max row._y...
|
||||
|
||||
# draw the data series
|
||||
#
|
||||
|
@ -29,16 +29,14 @@ class Morris.Donut extends Morris.EventEmitter
|
||||
# Create and render a donut chart.
|
||||
#
|
||||
constructor: (options) ->
|
||||
if not (this instanceof Morris.Donut)
|
||||
return new Morris.Donut(options)
|
||||
return new Morris.Donut(options) unless (@ instanceof Morris.Donut)
|
||||
@options = $.extend {}, @defaults, options
|
||||
|
||||
if typeof options.element is 'string'
|
||||
@el = $ document.getElementById(options.element)
|
||||
else
|
||||
@el = $ options.element
|
||||
|
||||
@options = $.extend {}, @defaults, options
|
||||
|
||||
if @el == null || @el.length == 0
|
||||
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)
|
||||
@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
|
||||
for value in @values
|
||||
if value == max_value
|
||||
|
@ -139,8 +139,8 @@ class Morris.Grid extends Morris.EventEmitter
|
||||
ymin = if @cumulative then 0 else null
|
||||
|
||||
if @options.goals.length > 0
|
||||
minGoal = Math.min.apply(null, @options.goals)
|
||||
maxGoal = Math.max.apply(null, @options.goals)
|
||||
minGoal = Math.min @options.goals...
|
||||
maxGoal = Math.max @options.goals...
|
||||
ymin = if ymin? then Math.min(ymin, minGoal) else minGoal
|
||||
ymax = if ymax? then Math.max(ymax, maxGoal) else maxGoal
|
||||
|
||||
@ -188,8 +188,8 @@ class Morris.Grid extends Morris.EventEmitter
|
||||
@events = []
|
||||
if @options.parseTime and @options.events.length > 0
|
||||
@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))
|
||||
@xmax = Math.max(@xmax, Math.max(@events...))
|
||||
@xmin = Math.min(@xmin, Math.min(@events...))
|
||||
|
||||
if @xmin is @xmax
|
||||
@xmin -= 1
|
||||
|
@ -52,7 +52,7 @@ class Morris.Line extends Morris.Grid
|
||||
row._x = @transX(row.x)
|
||||
row._y = for y in row.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
|
||||
#
|
||||
|
Loading…
Reference in New Issue
Block a user