Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to disable axes individually #253

Merged
merged 2 commits into from
Oct 12, 2013
Merged
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
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.axes
@drawXAxis() if @options.axes in [true, 'both', 'x']
@drawSeries()

# draw the x-axis labels
Expand Down
9 changes: 5 additions & 4 deletions lib/morris.grid.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class Morris.Grid extends Morris.EventEmitter
@ymin -= 1 if ymin
@ymax += 1

if @options.axes 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 @@ -241,10 +241,11 @@ class Morris.Grid extends Morris.EventEmitter
@right = @elementWidth - @options.padding
@top = @options.padding
@bottom = @elementHeight - @options.padding
if @options.axes
if @options.axes in [true, 'both', 'y']
yLabelWidths = for gridLine in @grid
@measureText(@yAxisFormat(gridLine)).width
@left += Math.max(yLabelWidths...)
if @options.axes in [true, 'both', 'x']
bottomOffsets = for i in [[email protected]]
@measureText(@data[i].text, [email protected]).height
@bottom -= Math.max(bottomOffsets...)
Expand Down Expand Up @@ -307,10 +308,10 @@ class Morris.Grid extends Morris.EventEmitter
# draw y axis labels, horizontal lines
#
drawGrid: ->
return if @options.grid is false and @options.axes 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.axes
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.axes
@drawXAxis() if @options.axes in [true, 'both', 'x']
@drawSeries()
if @options.hideHover is false
@displayHoverForRow(@data.length - 1)
Expand Down
44 changes: 24 additions & 20 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.