Merge branch 'master' into html-hover

Conflicts:
	lib/morris.line.coffee
	morris.js
	morris.min.js
This commit is contained in:
Olly Smith 2012-12-04 22:06:53 +00:00
commit 8080000a56
5 changed files with 18 additions and 19 deletions

View File

@ -118,4 +118,3 @@ class Morris.Bar extends Morris.Grid
hoverGetPosition: (index) ->
[x, y] = super(index)
[x, (@top + @bottom)/2 - @hoverHeight/2]

View File

@ -150,13 +150,13 @@ class Morris.Line extends Morris.Grid
@seriesPoints = ([] for i in [0...@options.ykeys.length])
for i in [@options.ykeys.length-1..0]
for row in @data
if row._y[i] == null
circle = null
else
if row._y[i]?
circle = @r.circle(row._x, row._y[i], @options.pointSize)
.attr('fill', @colorFor(row, i, 'point'))
.attr('stroke-width', @strokeWidthForSeries(i))
.attr('stroke', @strokeForSeries(i))
else
circle = null
@seriesPoints[i].push(circle)
# create a path for a data series
@ -175,9 +175,9 @@ class Morris.Line extends Morris.Grid
lg = grads[i - 1]
ix = (coord.x - prevCoord.x) / 4
x1 = prevCoord.x + ix
y1 = Math.max(bottom, prevCoord.y + ix * lg)
y1 = Math.min(bottom, prevCoord.y + ix * lg)
x2 = coord.x - ix
y2 = Math.max(bottom, coord.y - ix * g)
y2 = Math.min(bottom, coord.y - ix * g)
path += "C#{x1},#{y1},#{x2},#{y2},#{coord.x},#{coord.y}"
else
path += "L#{coord.x},#{coord.y}"

View File

@ -879,10 +879,10 @@
_results1 = [];
for (_k = 0, _len = _ref2.length; _k < _len; _k++) {
row = _ref2[_k];
if (row._y[i] === null) {
circle = null;
} else {
if (row._y[i] != null) {
circle = this.r.circle(row._x, row._y[i], this.options.pointSize).attr('fill', this.colorFor(row, i, 'point')).attr('stroke-width', this.strokeWidthForSeries(i)).attr('stroke', this.strokeForSeries(i));
} else {
circle = null;
}
_results1.push(this.seriesPoints[i].push(circle));
}
@ -910,9 +910,9 @@
lg = grads[i - 1];
ix = (coord.x - prevCoord.x) / 4;
x1 = prevCoord.x + ix;
y1 = Math.max(bottom, prevCoord.y + ix * lg);
y1 = Math.min(bottom, prevCoord.y + ix * lg);
x2 = coord.x - ix;
y2 = Math.max(bottom, coord.y - ix * g);
y2 = Math.min(bottom, coord.y - ix * g);
path += "C" + x1 + "," + y1 + "," + x2 + "," + y2 + "," + coord.x + "," + coord.y;
} else {
path += "L" + coord.x + "," + coord.y;

2
morris.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -118,25 +118,25 @@ describe 'Morris.Line', ->
it 'should generate a smooth line', ->
testData = [{x: 0, y: 10}, {x: 10, y: 0}, {x: 20, y: 10}]
path = Morris.Line.createPath(testData, true, 0)
path = Morris.Line.createPath(testData, true, 20)
path.should.equal 'M0,10C2.5,7.5,7.5,0,10,0C12.5,0,17.5,7.5,20,10'
it 'should generate a jagged line', ->
testData = [{x: 0, y: 10}, {x: 10, y: 0}, {x: 20, y: 10}]
path = Morris.Line.createPath(testData, false, 0)
path = Morris.Line.createPath(testData, false, 20)
path.should.equal 'M0,10L10,0L20,10'
it 'should prevent paths from descending below the bottom of the chart', ->
testData = [{x: 0, y: 20}, {x: 10, y: 10}, {x: 20, y: 30}]
path = Morris.Line.createPath(testData, true, 10)
path.should.equal 'M0,20C2.5,17.5,7.5,10,10,10C12.5,11.25,17.5,25,20,30'
testData = [{x: 0, y: 20}, {x: 10, y: 30}, {x: 20, y: 10}]
path = Morris.Line.createPath(testData, true, 30)
path.should.equal 'M0,20C2.5,22.5,7.5,30,10,30C12.5,28.75,17.5,15,20,10'
it 'should break the line at null values', ->
testData = [{x: 0, y: 10}, {x: 10, y: 0}, {x: 20, y: null}, {x: 30, y: 10}, {x: 40, y: 0}]
path = Morris.Line.createPath(testData, true, 0)
path = Morris.Line.createPath(testData, true, 20)
path.should.equal 'M0,10C2.5,7.5,7.5,2.5,10,0M30,10C32.5,7.5,37.5,2.5,40,0'
it 'should ignore leading and trailing null values', ->
testData = [{x: 0, y: null}, {x: 10, y: 10}, {x: 20, y: 0}, {x: 30, y: 10}, {x: 40, y: null}]
path = Morris.Line.createPath(testData, true, 0)
path = Morris.Line.createPath(testData, true, 20)
path.should.equal 'M10,10C12.5,7.5,17.5,0,20,0C22.5,0,27.5,7.5,30,10'