mirror of
https://github.com/morrisjs/morris.js.git
synced 2024-11-10 21:36:34 +01:00
Merge branch 'smooth-per-series' of https://github.com/tiraeth/morris.js into tiraeth-smooth-per-series
Conflicts: morris.min.js
This commit is contained in:
commit
66461001b7
@ -223,6 +223,15 @@ class Morris.Line
|
|||||||
transY: (y) =>
|
transY: (y) =>
|
||||||
return @options.marginTop + @height - (y - @ymin) * @dy
|
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(@options.ykeys[series], @options.smooth) > -1
|
||||||
|
true
|
||||||
|
else
|
||||||
|
false
|
||||||
|
|
||||||
# Clear and redraw the chart.
|
# Clear and redraw the chart.
|
||||||
#
|
#
|
||||||
# If you need to re-size your charts, call this method after changing the
|
# If you need to re-size your charts, call this method after changing the
|
||||||
@ -292,7 +301,7 @@ class Morris.Line
|
|||||||
for i in [@seriesCoords.length-1..0]
|
for i in [@seriesCoords.length-1..0]
|
||||||
coords = $.map(@seriesCoords[i], (c) -> c)
|
coords = $.map(@seriesCoords[i], (c) -> c)
|
||||||
if coords.length > 1
|
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)
|
@r.path(path)
|
||||||
.attr('stroke', @colorForSeries(i))
|
.attr('stroke', @colorForSeries(i))
|
||||||
.attr('stroke-width', @options.lineWidth)
|
.attr('stroke-width', @options.lineWidth)
|
||||||
@ -311,9 +320,10 @@ class Morris.Line
|
|||||||
# create a path for a data series
|
# create a path for a data series
|
||||||
#
|
#
|
||||||
# @private
|
# @private
|
||||||
createPath: (coords, top, left, bottom, right) ->
|
createPath: (series, coords, top, left, bottom, right) ->
|
||||||
path = ""
|
path = ""
|
||||||
if @options.smooth
|
|
||||||
|
if @shouldDrawSmooth(series)
|
||||||
grads = @gradients coords
|
grads = @gradients coords
|
||||||
for i in [0..coords.length-1]
|
for i in [0..coords.length-1]
|
||||||
c = coords[i]
|
c = coords[i]
|
||||||
|
18
morris.js
18
morris.js
@ -292,6 +292,8 @@
|
|||||||
|
|
||||||
this.updateHover = __bind(this.updateHover, this);
|
this.updateHover = __bind(this.updateHover, this);
|
||||||
|
|
||||||
|
this.shouldDrawSmooth = __bind(this.shouldDrawSmooth, this);
|
||||||
|
|
||||||
this.transY = __bind(this.transY, this);
|
this.transY = __bind(this.transY, this);
|
||||||
|
|
||||||
this.transX = __bind(this.transX, this);
|
this.transX = __bind(this.transX, this);
|
||||||
@ -558,6 +560,16 @@
|
|||||||
return this.options.marginTop + this.height - (y - this.ymin) * this.dy;
|
return this.options.marginTop + this.height - (y - this.ymin) * this.dy;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Line.prototype.shouldDrawSmooth = function(series) {
|
||||||
|
if (typeof this.options.smooth === 'boolean' && this.options.smooth) {
|
||||||
|
return true;
|
||||||
|
} else if (typeof this.options.smooth === 'object' && $.inArray(this.options.ykeys[series], this.options.smooth) > -1) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
Line.prototype.redraw = function() {
|
Line.prototype.redraw = function() {
|
||||||
this.r.clear();
|
this.r.clear();
|
||||||
this.calc();
|
this.calc();
|
||||||
@ -620,7 +632,7 @@
|
|||||||
return c;
|
return c;
|
||||||
});
|
});
|
||||||
if (coords.length > 1) {
|
if (coords.length > 1) {
|
||||||
path = this.createPath(coords, this.options.marginTop, this.left, this.options.marginTop + this.height, this.left + this.width);
|
path = this.createPath(i, coords, this.options.marginTop, this.left, this.options.marginTop + this.height, this.left + this.width);
|
||||||
this.r.path(path).attr('stroke', this.colorForSeries(i)).attr('stroke-width', this.options.lineWidth);
|
this.r.path(path).attr('stroke', this.colorForSeries(i)).attr('stroke-width', this.options.lineWidth);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -653,10 +665,10 @@
|
|||||||
return _results;
|
return _results;
|
||||||
};
|
};
|
||||||
|
|
||||||
Line.prototype.createPath = function(coords, top, left, bottom, right) {
|
Line.prototype.createPath = function(series, coords, top, left, bottom, right) {
|
||||||
var c, g, grads, i, ix, lc, lg, path, x1, x2, y1, y2, _i, _ref;
|
var c, g, grads, i, ix, lc, lg, path, x1, x2, y1, y2, _i, _ref;
|
||||||
path = "";
|
path = "";
|
||||||
if (this.options.smooth) {
|
if (this.shouldDrawSmooth(series)) {
|
||||||
grads = this.gradients(coords);
|
grads = this.gradients(coords);
|
||||||
for (i = _i = 0, _ref = coords.length - 1; 0 <= _ref ? _i <= _ref : _i >= _ref; i = 0 <= _ref ? ++_i : --_i) {
|
for (i = _i = 0, _ref = coords.length - 1; 0 <= _ref ? _i <= _ref : _i >= _ref; i = 0 <= _ref ? ++_i : --_i) {
|
||||||
c = coords[i];
|
c = coords[i];
|
||||||
|
2
morris.min.js
vendored
2
morris.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user