Skip to content

Commit d142048

Browse files
committed
axes option can be true, false, 'both', 'x', 'y'
1 parent cccf319 commit d142048

File tree

5 files changed

+33
-42
lines changed

5 files changed

+33
-42
lines changed

lib/morris.bar.coffee

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class Morris.Bar extends Morris.Grid
4848
# Draws the bar chart.
4949
#
5050
draw: ->
51-
@drawXAxis() if @options.xaxis
51+
@drawXAxis() if @options.axes in [true, 'both', 'x']
5252
@drawSeries()
5353

5454
# draw the x-axis labels

lib/morris.grid.coffee

+6-12
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ class Morris.Grid extends Morris.EventEmitter
2121
if typeof @options.units is 'string'
2222
@options.postUnits = options.units
2323

24-
# backwards compatibility for axes -> xaxis, yaxis
25-
if @options.axes is false
26-
@options.xaxis = false
27-
@options.yaxis = false
28-
2924
# the raphael drawing instance
3025
@raphael = new Raphael(@el[0])
3126

@@ -64,8 +59,7 @@ class Morris.Grid extends Morris.EventEmitter
6459
#
6560
gridDefaults:
6661
dateFormat: null
67-
xaxis: true
68-
yaxis: true
62+
axes: true
6963
grid: true
7064
gridLineColor: '#aaa'
7165
gridStrokeWidth: 0.5
@@ -178,7 +172,7 @@ class Morris.Grid extends Morris.EventEmitter
178172
@ymin -= 1 if ymin
179173
@ymax += 1
180174

181-
if @options.yaxis is true or @options.grid is true
175+
if @options.axes in [true, 'both', 'y'] or @options.grid is true
182176
if (@options.ymax == @gridDefaults.ymax and
183177
@options.ymin == @gridDefaults.ymin)
184178
# calculate 'magic' grid placement
@@ -247,11 +241,11 @@ class Morris.Grid extends Morris.EventEmitter
247241
@right = @elementWidth - @options.padding
248242
@top = @options.padding
249243
@bottom = @elementHeight - @options.padding
250-
if @options.yaxis
244+
if @options.axes in [true, 'both', 'y']
251245
yLabelWidths = for gridLine in @grid
252246
@measureText(@yAxisFormat(gridLine)).width
253247
@left += Math.max(yLabelWidths...)
254-
if @options.xaxis
248+
if @options.axes in [true, 'both', 'x']
255249
bottomOffsets = for i in [0...@data.length]
256250
@measureText(@data[i].text, -@options.xLabelAngle).height
257251
@bottom -= Math.max(bottomOffsets...)
@@ -314,10 +308,10 @@ class Morris.Grid extends Morris.EventEmitter
314308
# draw y axis labels, horizontal lines
315309
#
316310
drawGrid: ->
317-
return if @options.grid is false and @options.yaxis is false
311+
return if @options.grid is false and @options.axes not in [true, 'both', 'y']
318312
for lineY in @grid
319313
y = @transY(lineY)
320-
if @options.yaxis
314+
if @options.axes in [true, 'both', 'y']
321315
@drawYAxisLabel(@left - @options.padding / 2, y, @yAxisFormat(lineY))
322316
if @options.grid
323317
@drawGridLine("M#{@left},#{y}H#{@left + @width}")

lib/morris.line.coffee

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ class Morris.Line extends Morris.Grid
133133
# Draws the line chart.
134134
#
135135
draw: ->
136-
@drawXAxis() if @options.xaxis
136+
@drawXAxis() if @options.axes in [true, 'both', 'x']
137137
@drawSeries()
138138
if @options.hideHover is false
139139
@displayHoverForRow(@data.length - 1)

morris.js

+24-27
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

morris.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)