diff --git a/lib/morris.bar.coffee b/lib/morris.bar.coffee index ba554c1..fba8037 100644 --- a/lib/morris.bar.coffee +++ b/lib/morris.bar.coffee @@ -30,6 +30,7 @@ class Morris.Bar extends Morris.Grid barRadius: [0, 0, 0, 0] xLabelMargin: 50 horizontal: false + shown: true # Do any size-related calculations # @@ -127,10 +128,16 @@ class Morris.Bar extends Morris.Grid # # @private drawSeries: -> - numBars = if @options.stacked then 1 else @options.ykeys.length - groupWidth = @xSize / @options.data.length + if @options.stacked + numBars = 1 + else + numBars = 0 + for i in [0..@options.ykeys.length] + if @hasToShow(i) + numBars += 1 + barWidth = (groupWidth * @options.barSizeRatio - @options.barGap * (numBars - 1)) / numBars barWidth = Math.min(barWidth, @options.barSize) if @options.barSize spaceLeft = groupWidth - barWidth * numBars - @options.barGap * (numBars - 1) @@ -139,6 +146,8 @@ class Morris.Bar extends Morris.Grid @bars = for row, idx in @data lastTop = 0 for ypos, sidx in row._y + if not @hasToShow(sidx) + continue if ypos != null if zeroPos top = Math.min(ypos, zeroPos) diff --git a/lib/morris.grid.coffee b/lib/morris.grid.coffee index 61b9e7d..2bf5309 100644 --- a/lib/morris.grid.coffee +++ b/lib/morris.grid.coffee @@ -172,7 +172,7 @@ class Morris.Grid extends Morris.EventEmitter yval = row[ykey] yval = parseFloat(yval) if typeof yval is 'string' yval = null if yval? and typeof yval isnt 'number' - if yval? + if yval? and @hasToShow(idx) if @cumulative total += yval else @@ -489,6 +489,10 @@ class Morris.Grid extends Morris.EventEmitter @raphael.setSize @el.width(), @el.height() @redraw() + hasToShow: (i) => + @options.shown is true or @options.shown[i] is true + + # Parse a date into a javascript timestamp # # diff --git a/lib/morris.line.coffee b/lib/morris.line.coffee index a33ad5a..7f50d94 100644 --- a/lib/morris.line.coffee +++ b/lib/morris.line.coffee @@ -31,6 +31,7 @@ class Morris.Line extends Morris.Grid pointStrokeColors: ['#ffffff'] pointFillColors: [] smooth: true + shown: true xLabels: 'auto' xLabelFormat: null xLabelMargin: 24 @@ -194,13 +195,16 @@ class Morris.Line extends Morris.Grid drawSeries: -> @seriesPoints = [] for i in [@options.ykeys.length-1..0] - if @options.trendLine isnt false and - @options.trendLine is true or @options.trendLine[i] is true - @_drawTrendLine i + if @hasToShow(i) + if @options.trendLine isnt false and + @options.trendLine is true or @options.trendLine[i] is true + @_drawTrendLine i + + @_drawLineFor i - @_drawLineFor i for i in [@options.ykeys.length-1..0] - @_drawPointFor i + if @hasToShow(i) + @_drawPointFor i _drawPointFor: (index) -> @seriesPoints[index] = []