Skip to content

Commit

Permalink
axes option can be true, false, 'both', 'x', 'y'
Browse files Browse the repository at this point in the history
  • Loading branch information
omarkhan committed Jun 23, 2013
1 parent cccf319 commit d142048
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 42 deletions.
2 changes: 1 addition & 1 deletion lib/morris.bar.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Morris.Bar extends Morris.Grid
# Draws the bar chart.
#
draw: ->
@drawXAxis() if @options.xaxis
@drawXAxis() if @options.axes in [true, 'both', 'x']
@drawSeries()

# draw the x-axis labels
Expand Down
18 changes: 6 additions & 12 deletions lib/morris.grid.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ class Morris.Grid extends Morris.EventEmitter
if typeof @options.units is 'string'
@options.postUnits = options.units

# backwards compatibility for axes -> xaxis, yaxis
if @options.axes is false
@options.xaxis = false
@options.yaxis = false

# the raphael drawing instance
@raphael = new Raphael(@el[0])

Expand Down Expand Up @@ -64,8 +59,7 @@ class Morris.Grid extends Morris.EventEmitter
#
gridDefaults:
dateFormat: null
xaxis: true
yaxis: true
axes: true
grid: true
gridLineColor: '#aaa'
gridStrokeWidth: 0.5
Expand Down Expand Up @@ -178,7 +172,7 @@ class Morris.Grid extends Morris.EventEmitter
@ymin -= 1 if ymin
@ymax += 1

if @options.yaxis is true or @options.grid is true
if @options.axes in [true, 'both', 'y'] or @options.grid is true
if (@options.ymax == @gridDefaults.ymax and
@options.ymin == @gridDefaults.ymin)
# calculate 'magic' grid placement
Expand Down Expand Up @@ -247,11 +241,11 @@ class Morris.Grid extends Morris.EventEmitter
@right = @elementWidth - @options.padding
@top = @options.padding
@bottom = @elementHeight - @options.padding
if @options.yaxis
if @options.axes in [true, 'both', 'y']
yLabelWidths = for gridLine in @grid
@measureText(@yAxisFormat(gridLine)).width
@left += Math.max(yLabelWidths...)
if @options.xaxis
if @options.axes in [true, 'both', 'x']
bottomOffsets = for i in [0...@data.length]
@measureText(@data[i].text, -@options.xLabelAngle).height
@bottom -= Math.max(bottomOffsets...)
Expand Down Expand Up @@ -314,10 +308,10 @@ class Morris.Grid extends Morris.EventEmitter
# draw y axis labels, horizontal lines
#
drawGrid: ->
return if @options.grid is false and @options.yaxis is false
return if @options.grid is false and @options.axes not in [true, 'both', 'y']
for lineY in @grid
y = @transY(lineY)
if @options.yaxis
if @options.axes in [true, 'both', 'y']
@drawYAxisLabel(@left - @options.padding / 2, y, @yAxisFormat(lineY))
if @options.grid
@drawGridLine("M#{@left},#{y}H#{@left + @width}")
Expand Down
2 changes: 1 addition & 1 deletion lib/morris.line.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class Morris.Line extends Morris.Grid
# Draws the line chart.
#
draw: ->
@drawXAxis() if @options.xaxis
@drawXAxis() if @options.axes in [true, 'both', 'x']
@drawSeries()
if @options.hideHover is false
@displayHoverForRow(@data.length - 1)
Expand Down
51 changes: 24 additions & 27 deletions morris.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion morris.min.js

Large diffs are not rendered by default.

0 comments on commit d142048

Please sign in to comment.