mirror of
https://github.com/morrisjs/morris.js.git
synced 2024-11-11 05:46:37 +01:00
Merge branch 'master' into html-hover
Conflicts: lib/morris.line.coffee morris.js morris.min.js
This commit is contained in:
commit
8080000a56
@ -118,4 +118,3 @@ class Morris.Bar extends Morris.Grid
|
|||||||
hoverGetPosition: (index) ->
|
hoverGetPosition: (index) ->
|
||||||
[x, y] = super(index)
|
[x, y] = super(index)
|
||||||
[x, (@top + @bottom)/2 - @hoverHeight/2]
|
[x, (@top + @bottom)/2 - @hoverHeight/2]
|
||||||
|
|
||||||
|
@ -150,13 +150,13 @@ class Morris.Line extends Morris.Grid
|
|||||||
@seriesPoints = ([] for i in [0...@options.ykeys.length])
|
@seriesPoints = ([] for i in [0...@options.ykeys.length])
|
||||||
for i in [@options.ykeys.length-1..0]
|
for i in [@options.ykeys.length-1..0]
|
||||||
for row in @data
|
for row in @data
|
||||||
if row._y[i] == null
|
if row._y[i]?
|
||||||
circle = null
|
|
||||||
else
|
|
||||||
circle = @r.circle(row._x, row._y[i], @options.pointSize)
|
circle = @r.circle(row._x, row._y[i], @options.pointSize)
|
||||||
.attr('fill', @colorFor(row, i, 'point'))
|
.attr('fill', @colorFor(row, i, 'point'))
|
||||||
.attr('stroke-width', @strokeWidthForSeries(i))
|
.attr('stroke-width', @strokeWidthForSeries(i))
|
||||||
.attr('stroke', @strokeForSeries(i))
|
.attr('stroke', @strokeForSeries(i))
|
||||||
|
else
|
||||||
|
circle = null
|
||||||
@seriesPoints[i].push(circle)
|
@seriesPoints[i].push(circle)
|
||||||
|
|
||||||
# create a path for a data series
|
# create a path for a data series
|
||||||
@ -175,9 +175,9 @@ class Morris.Line extends Morris.Grid
|
|||||||
lg = grads[i - 1]
|
lg = grads[i - 1]
|
||||||
ix = (coord.x - prevCoord.x) / 4
|
ix = (coord.x - prevCoord.x) / 4
|
||||||
x1 = prevCoord.x + ix
|
x1 = prevCoord.x + ix
|
||||||
y1 = Math.max(bottom, prevCoord.y + ix * lg)
|
y1 = Math.min(bottom, prevCoord.y + ix * lg)
|
||||||
x2 = coord.x - ix
|
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}"
|
path += "C#{x1},#{y1},#{x2},#{y2},#{coord.x},#{coord.y}"
|
||||||
else
|
else
|
||||||
path += "L#{coord.x},#{coord.y}"
|
path += "L#{coord.x},#{coord.y}"
|
||||||
|
10
morris.js
10
morris.js
@ -879,10 +879,10 @@
|
|||||||
_results1 = [];
|
_results1 = [];
|
||||||
for (_k = 0, _len = _ref2.length; _k < _len; _k++) {
|
for (_k = 0, _len = _ref2.length; _k < _len; _k++) {
|
||||||
row = _ref2[_k];
|
row = _ref2[_k];
|
||||||
if (row._y[i] === null) {
|
if (row._y[i] != null) {
|
||||||
circle = null;
|
|
||||||
} else {
|
|
||||||
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));
|
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));
|
_results1.push(this.seriesPoints[i].push(circle));
|
||||||
}
|
}
|
||||||
@ -910,9 +910,9 @@
|
|||||||
lg = grads[i - 1];
|
lg = grads[i - 1];
|
||||||
ix = (coord.x - prevCoord.x) / 4;
|
ix = (coord.x - prevCoord.x) / 4;
|
||||||
x1 = prevCoord.x + ix;
|
x1 = prevCoord.x + ix;
|
||||||
y1 = Math.max(bottom, prevCoord.y + ix * lg);
|
y1 = Math.min(bottom, prevCoord.y + ix * lg);
|
||||||
x2 = coord.x - ix;
|
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;
|
path += "C" + x1 + "," + y1 + "," + x2 + "," + y2 + "," + coord.x + "," + coord.y;
|
||||||
} else {
|
} else {
|
||||||
path += "L" + coord.x + "," + coord.y;
|
path += "L" + coord.x + "," + coord.y;
|
||||||
|
2
morris.min.js
vendored
2
morris.min.js
vendored
File diff suppressed because one or more lines are too long
@ -118,25 +118,25 @@ describe 'Morris.Line', ->
|
|||||||
|
|
||||||
it 'should generate a smooth line', ->
|
it 'should generate a smooth line', ->
|
||||||
testData = [{x: 0, y: 10}, {x: 10, y: 0}, {x: 20, y: 10}]
|
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'
|
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', ->
|
it 'should generate a jagged line', ->
|
||||||
testData = [{x: 0, y: 10}, {x: 10, y: 0}, {x: 20, y: 10}]
|
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'
|
path.should.equal 'M0,10L10,0L20,10'
|
||||||
|
|
||||||
it 'should prevent paths from descending below the bottom of the chart', ->
|
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}]
|
testData = [{x: 0, y: 20}, {x: 10, y: 30}, {x: 20, y: 10}]
|
||||||
path = Morris.Line.createPath(testData, true, 10)
|
path = Morris.Line.createPath(testData, true, 30)
|
||||||
path.should.equal 'M0,20C2.5,17.5,7.5,10,10,10C12.5,11.25,17.5,25,20,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', ->
|
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}]
|
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'
|
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', ->
|
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}]
|
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'
|
path.should.equal 'M10,10C12.5,7.5,17.5,0,20,0C22.5,0,27.5,7.5,30,10'
|
||||||
|
Loading…
Reference in New Issue
Block a user