Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions lib/morris.bar.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ class Morris.Bar extends Morris.Grid
leftPadding = spaceLeft / 2
zeroPos = if @ymin <= 0 and @ymax >= 0 then @transY(0) else null
@bars = for row, idx in @data
lastTop = 0
lastTop = null
lastBottom = null
for ypos, sidx in row._y
if not @hasToShow(sidx)
continue
Expand All @@ -166,16 +167,18 @@ class Morris.Bar extends Morris.Grid
else
@drawBar(@yStart, @xStart + idx * groupWidth, @ySize, groupWidth, @options.verticalGridColor, @options.verticalGridOpacity, @options.barRadius)


top -= lastTop if @options.stacked
if not @options.horizontal
top += lastTop-bottom if @options.stacked and lastTop?
@drawBar(left, top, barWidth, size, @colorFor(row, sidx, 'bar'),
@options.barOpacity, @options.barRadius)
lastTop += size
lastTop = top
else
if @options.stacked and lastBottom?
bottom += lastBottom-top
top = lastBottom
@drawBar(top, left, size, barWidth, @colorFor(row, sidx, 'bar'),
@options.barOpacity, @options.barRadius)
lastTop -= size
lastBottom = bottom


else
Expand Down
5 changes: 4 additions & 1 deletion lib/morris.grid.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,10 @@ class Morris.Grid extends Morris.EventEmitter
yval = null if yval? and typeof yval isnt 'number'
if yval? and @hasToShow(idx)
if @cumulative
total += yval
if total < 0 and yval > 0
total = yval
else
total += yval
else
if ymax?
ymax = Math.max(yval, ymax)
Expand Down