Blame | Last modification | View Log | Download | RSS feed
class Morris.Area extends Morris.Line# Initialise#areaDefaults =fillOpacity: 'auto'behaveLikeLine: falseconstructor: (options) ->return new Morris.Area(options) unless (@ instanceof Morris.Area)areaOptions = $.extend {}, areaDefaults, options@cumulative = not areaOptions.behaveLikeLineif areaOptions.fillOpacity is 'auto'areaOptions.fillOpacity = if areaOptions.behaveLikeLine then .8 else 1super(areaOptions)# calculate series data point coordinates## @privatecalcPoints: ->for row in @datarow._x = @transX(row.x)total = 0row._y = for y in row.yif @options.behaveLikeLine@transY(y)elsetotal += (y || 0)@transY(total)row._ymax = Math.max row._y...# draw the data series## @privatedrawSeries: ->@seriesPoints = []if @options.behaveLikeLinerange = [0..@options.ykeys.length-1]elserange = [@options.ykeys.length-1..0]for i in range@_drawFillFor i@_drawLineFor i@_drawPointFor i_drawFillFor: (index) ->path = @paths[index]if path isnt nullpath = path + "L#{@transX(@xmax)},#{@bottom}L#{@transX(@xmin)},#{@bottom}Z"@drawFilledPath path, @fillForSeries(index)fillForSeries: (i) ->color = Raphael.rgb2hsl @colorFor(@data[i], i, 'line')Raphael.hsl(color.h,if @options.behaveLikeLine then color.s * 0.9 else color.s * 0.75,Math.min(0.98, if @options.behaveLikeLine then color.l * 1.2 else color.l * 1.25))drawFilledPath: (path, fill) ->@raphael.path(path).attr('fill', fill).attr('fill-opacity', @options.fillOpacity).attr('stroke', 'none')