mirror of
https://github.com/morrisjs/morris.js.git
synced 2024-11-10 21:36:34 +01:00
Add feature to not show certain plots, but still show values in the legend
This commit is contained in:
parent
d5cf1410ed
commit
877e341ac4
@ -29,6 +29,7 @@ class Morris.Bar extends Morris.Grid
|
|||||||
barOpacity: 1.0
|
barOpacity: 1.0
|
||||||
barRadius: [0, 0, 0, 0]
|
barRadius: [0, 0, 0, 0]
|
||||||
xLabelMargin: 50
|
xLabelMargin: 50
|
||||||
|
shown: true
|
||||||
|
|
||||||
# Do any size-related calculations
|
# Do any size-related calculations
|
||||||
#
|
#
|
||||||
@ -90,7 +91,14 @@ class Morris.Bar extends Morris.Grid
|
|||||||
# @private
|
# @private
|
||||||
drawSeries: ->
|
drawSeries: ->
|
||||||
groupWidth = @width / @options.data.length
|
groupWidth = @width / @options.data.length
|
||||||
numBars = if @options.stacked then 1 else @options.ykeys.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 = (groupWidth * @options.barSizeRatio - @options.barGap * (numBars - 1)) / numBars
|
||||||
barWidth = Math.min(barWidth, @options.barSize) if @options.barSize
|
barWidth = Math.min(barWidth, @options.barSize) if @options.barSize
|
||||||
spaceLeft = groupWidth - barWidth * numBars - @options.barGap * (numBars - 1)
|
spaceLeft = groupWidth - barWidth * numBars - @options.barGap * (numBars - 1)
|
||||||
@ -99,6 +107,8 @@ class Morris.Bar extends Morris.Grid
|
|||||||
@bars = for row, idx in @data
|
@bars = for row, idx in @data
|
||||||
lastTop = 0
|
lastTop = 0
|
||||||
for ypos, sidx in row._y
|
for ypos, sidx in row._y
|
||||||
|
if not @hasToShow(sidx)
|
||||||
|
continue
|
||||||
if ypos != null
|
if ypos != null
|
||||||
if zeroPos
|
if zeroPos
|
||||||
top = Math.min(ypos, zeroPos)
|
top = Math.min(ypos, zeroPos)
|
||||||
|
@ -172,7 +172,7 @@ class Morris.Grid extends Morris.EventEmitter
|
|||||||
yval = row[ykey]
|
yval = row[ykey]
|
||||||
yval = parseFloat(yval) if typeof yval is 'string'
|
yval = parseFloat(yval) if typeof yval is 'string'
|
||||||
yval = null if yval? and typeof yval isnt 'number'
|
yval = null if yval? and typeof yval isnt 'number'
|
||||||
if yval?
|
if yval? and @hasToShow(idx)
|
||||||
if @cumulative
|
if @cumulative
|
||||||
total += yval
|
total += yval
|
||||||
else
|
else
|
||||||
@ -410,6 +410,10 @@ class Morris.Grid extends Morris.EventEmitter
|
|||||||
@raphael.setSize @el.width(), @el.height()
|
@raphael.setSize @el.width(), @el.height()
|
||||||
@redraw()
|
@redraw()
|
||||||
|
|
||||||
|
hasToShow: (i) =>
|
||||||
|
@options.shown is true or @options.shown[i] is true
|
||||||
|
|
||||||
|
|
||||||
# Parse a date into a javascript timestamp
|
# Parse a date into a javascript timestamp
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
@ -31,6 +31,7 @@ class Morris.Line extends Morris.Grid
|
|||||||
pointStrokeColors: ['#ffffff']
|
pointStrokeColors: ['#ffffff']
|
||||||
pointFillColors: []
|
pointFillColors: []
|
||||||
smooth: true
|
smooth: true
|
||||||
|
shown: true
|
||||||
xLabels: 'auto'
|
xLabels: 'auto'
|
||||||
xLabelFormat: null
|
xLabelFormat: null
|
||||||
xLabelMargin: 24
|
xLabelMargin: 24
|
||||||
@ -184,9 +185,12 @@ class Morris.Line extends Morris.Grid
|
|||||||
drawSeries: ->
|
drawSeries: ->
|
||||||
@seriesPoints = []
|
@seriesPoints = []
|
||||||
for i in [@options.ykeys.length-1..0]
|
for i in [@options.ykeys.length-1..0]
|
||||||
@_drawLineFor i
|
if @hasToShow(i)
|
||||||
|
@_drawLineFor i
|
||||||
|
|
||||||
for i in [@options.ykeys.length-1..0]
|
for i in [@options.ykeys.length-1..0]
|
||||||
@_drawPointFor i
|
if @hasToShow(i)
|
||||||
|
@_drawPointFor i
|
||||||
|
|
||||||
_drawPointFor: (index) ->
|
_drawPointFor: (index) ->
|
||||||
@seriesPoints[index] = []
|
@seriesPoints[index] = []
|
||||||
|
Loading…
Reference in New Issue
Block a user