making point size customizable per line as well

This commit is contained in:
David Gil 2013-08-20 03:39:43 +02:00
parent cdfe8ba62d
commit f4478828e4
3 changed files with 22 additions and 7 deletions

View file

@ -198,7 +198,7 @@ class Morris.Line extends Morris.Grid
for row in @data
circle = null
if row._y[index]?
circle = @drawLinePoint(row._x, row._y[index], @options.pointSize, @colorFor(row, index, 'point'), index)
circle = @drawLinePoint(row._x, row._y[index], @colorFor(row, index, 'point'), index)
@seriesPoints[index].push(circle)
_drawLineFor: (index) ->
@ -286,8 +286,8 @@ class Morris.Line extends Morris.Grid
.attr('stroke', lineColor)
.attr('stroke-width', @lineWidthForSeries(lineIndex))
drawLinePoint: (xPos, yPos, size, pointColor, lineIndex) ->
@raphael.circle(xPos, yPos, size)
drawLinePoint: (xPos, yPos, pointColor, lineIndex) ->
@raphael.circle(xPos, yPos, @pointSizeForSeries(lineIndex))
.attr('fill', pointColor)
.attr('stroke-width', @strokeWidthForSeries(lineIndex))
.attr('stroke', @strokeForSeries(lineIndex))
@ -307,6 +307,13 @@ class Morris.Line extends Morris.Grid
else
@options.lineWidth
# @private
pointSizeForSeries: (index) ->
if (@options.pointSize instanceof Array)
@options.pointSize[index % @options.pointSize.length]
else
@options.pointSize
# generate a series of label, timestamp pairs for x-axis labels
#
# @private

View file

@ -914,7 +914,7 @@
row = _ref[_i];
circle = null;
if (row._y[index] != null) {
circle = this.drawLinePoint(row._x, row._y[index], this.options.pointSize, this.colorFor(row, index, 'point'), index);
circle = this.drawLinePoint(row._x, row._y[index], this.colorFor(row, index, 'point'), index);
}
_results.push(this.seriesPoints[index].push(circle));
}
@ -1033,8 +1033,8 @@
return this.raphael.path(path).attr('stroke', lineColor).attr('stroke-width', this.lineWidthForSeries(lineIndex));
};
Line.prototype.drawLinePoint = function(xPos, yPos, size, pointColor, lineIndex) {
return this.raphael.circle(xPos, yPos, size).attr('fill', pointColor).attr('stroke-width', this.strokeWidthForSeries(lineIndex)).attr('stroke', this.strokeForSeries(lineIndex));
Line.prototype.drawLinePoint = function(xPos, yPos, pointColor, lineIndex) {
return this.raphael.circle(xPos, yPos, this.pointSizeForSeries(lineIndex)).attr('fill', pointColor).attr('stroke-width', this.strokeWidthForSeries(lineIndex)).attr('stroke', this.strokeForSeries(lineIndex));
};
Line.prototype.strokeWidthForSeries = function(index) {
@ -1053,6 +1053,14 @@
}
};
Line.prototype.pointSizeForSeries = function(index) {
if (this.options.pointSize instanceof Array) {
return this.options.pointSize[index % this.options.pointSize.length];
} else {
return this.options.pointSize;
}
};
return Line;
})(Morris.Grid);

2
morris.min.js vendored

File diff suppressed because one or more lines are too long