Skip to content

Commit

Permalink
Make sure x-axis labels don't overflow.
Browse files Browse the repository at this point in the history
Fixes #63.
  • Loading branch information
oesmith committed Jun 8, 2012
1 parent 0015b28 commit acfec20
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions morris.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,10 @@ class Morris.Line
.attr('font-size', @options.gridTextSize)
.attr('fill', @options.gridTextColor)
labelBox = label.getBBox()
# ensure a minimum of `xLabelMargin` pixels between labels
if prevLabelMargin is null or prevLabelMargin <= labelBox.x
# ensure a minimum of `xLabelMargin` pixels between labels, and ensure
# labels don't overflow the container
if (prevLabelMargin is null or prevLabelMargin <= labelBox.x) and
labelBox.x >= 0 and (labelBox.x + labelBox.width) < @el.width()
prevLabelMargin = labelBox.x + labelBox.width + xLabelMargin
else
label.remove()
Expand Down
2 changes: 1 addition & 1 deletion morris.js

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

Loading

0 comments on commit acfec20

Please sign in to comment.