Skip to content

Commit

Permalink
added ability to set smooth parameter per series
Browse files Browse the repository at this point in the history
  • Loading branch information
tiraeth committed Oct 15, 2012
1 parent 60eae6a commit 9773a69
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
18 changes: 14 additions & 4 deletions lib/morris.line.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,21 @@ class Morris.Line
if @xvals.length is 1
@left + @width / 2
else
@left + (x - @xmin) * @dx
@left + (x - @xmin) * @dx

# @private
transY: (y) =>
return @options.marginTop + @height - (y - @ymin) * @dy

# @private
shouldDrawSmooth: (series) =>
if typeof @options.smooth is 'boolean' && @options.smooth
true
else if typeof @options.smooth is 'object' and $.inArray(@seriesLabels[series], @options.smooth) > -1
true
else
false

# Clear and redraw the chart.
#
# If you need to re-size your charts, call this method after changing the
Expand Down Expand Up @@ -288,7 +297,7 @@ class Morris.Line
for i in [@seriesCoords.length-1..0]
coords = $.map(@seriesCoords[i], (c) -> c)
if coords.length > 1
path = @createPath coords, @options.marginTop, @left, @options.marginTop + @height, @left + @width
path = @createPath i, coords, @options.marginTop, @left, @options.marginTop + @height, @left + @width
@r.path(path)
.attr('stroke', @colorForSeries(i))
.attr('stroke-width', @options.lineWidth)
Expand All @@ -307,9 +316,10 @@ class Morris.Line
# create a path for a data series
#
# @private
createPath: (coords, top, left, bottom, right) ->
createPath: (series, coords, top, left, bottom, right) ->
path = ""
if @options.smooth

if @shouldDrawSmooth(series)
grads = @gradients coords
for i in [0..coords.length-1]
c = coords[i]
Expand Down
18 changes: 15 additions & 3 deletions morris.js

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

Loading

0 comments on commit 9773a69

Please sign in to comment.