mirror of
https://github.com/morrisjs/morris.js.git
synced 2024-11-11 05:46:37 +01:00
pointGrow and pointShrink must adapt to the point size position of the index
This commit is contained in:
parent
f4478828e4
commit
92d7790908
@ -7,9 +7,6 @@ class Morris.Line extends Morris.Grid
|
|||||||
|
|
||||||
init: ->
|
init: ->
|
||||||
# Some instance variables for later
|
# Some instance variables for later
|
||||||
@pointGrow = Raphael.animation r: @options.pointSize + 3, 25, 'linear'
|
|
||||||
@pointShrink = Raphael.animation r: @options.pointSize, 25, 'linear'
|
|
||||||
|
|
||||||
if @options.hideHover isnt 'always'
|
if @options.hideHover isnt 'always'
|
||||||
@hover = new Morris.Hover(parent: @el)
|
@hover = new Morris.Hover(parent: @el)
|
||||||
@on('hovermove', @onHoverMove)
|
@on('hovermove', @onHoverMove)
|
||||||
@ -259,11 +256,11 @@ class Morris.Line extends Morris.Grid
|
|||||||
if @prevHilight isnt null and @prevHilight isnt index
|
if @prevHilight isnt null and @prevHilight isnt index
|
||||||
for i in [0..@seriesPoints.length-1]
|
for i in [0..@seriesPoints.length-1]
|
||||||
if @seriesPoints[i][@prevHilight]
|
if @seriesPoints[i][@prevHilight]
|
||||||
@seriesPoints[i][@prevHilight].animate @pointShrink
|
@seriesPoints[i][@prevHilight].animate @pointShrinkSeries(index)
|
||||||
if index isnt null and @prevHilight isnt index
|
if index isnt null and @prevHilight isnt index
|
||||||
for i in [0..@seriesPoints.length-1]
|
for i in [0..@seriesPoints.length-1]
|
||||||
if @seriesPoints[i][index]
|
if @seriesPoints[i][index]
|
||||||
@seriesPoints[i][index].animate @pointGrow
|
@seriesPoints[i][index].animate @pointGrowSeries(index)
|
||||||
@prevHilight = index
|
@prevHilight = index
|
||||||
|
|
||||||
colorFor: (row, sidx, type) ->
|
colorFor: (row, sidx, type) ->
|
||||||
@ -310,10 +307,22 @@ class Morris.Line extends Morris.Grid
|
|||||||
# @private
|
# @private
|
||||||
pointSizeForSeries: (index) ->
|
pointSizeForSeries: (index) ->
|
||||||
if (@options.pointSize instanceof Array)
|
if (@options.pointSize instanceof Array)
|
||||||
|
console.log(@options.pointSize)
|
||||||
|
console.log(index)
|
||||||
|
console.log(@options.pointSize.length)
|
||||||
|
console.log(index % @options.pointSize.length)
|
||||||
@options.pointSize[index % @options.pointSize.length]
|
@options.pointSize[index % @options.pointSize.length]
|
||||||
else
|
else
|
||||||
@options.pointSize
|
@options.pointSize
|
||||||
|
|
||||||
|
# @private
|
||||||
|
pointGrowSeries: (index) ->
|
||||||
|
Raphael.animation r: @pointSizeForSeries(index) + 3, 25, 'linear'
|
||||||
|
|
||||||
|
# @private
|
||||||
|
pointShrinkSeries: (index) ->
|
||||||
|
Raphael.animation r: @pointSizeForSeries(index), 25, 'linear'
|
||||||
|
|
||||||
# generate a series of label, timestamp pairs for x-axis labels
|
# generate a series of label, timestamp pairs for x-axis labels
|
||||||
#
|
#
|
||||||
# @private
|
# @private
|
||||||
|
26
morris.js
26
morris.js
@ -650,12 +650,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
Line.prototype.init = function() {
|
Line.prototype.init = function() {
|
||||||
this.pointGrow = Raphael.animation({
|
|
||||||
r: this.options.pointSize + 3
|
|
||||||
}, 25, 'linear');
|
|
||||||
this.pointShrink = Raphael.animation({
|
|
||||||
r: this.options.pointSize
|
|
||||||
}, 25, 'linear');
|
|
||||||
if (this.options.hideHover !== 'always') {
|
if (this.options.hideHover !== 'always') {
|
||||||
this.hover = new Morris.Hover({
|
this.hover = new Morris.Hover({
|
||||||
parent: this.el
|
parent: this.el
|
||||||
@ -1001,14 +995,14 @@
|
|||||||
if (this.prevHilight !== null && this.prevHilight !== index) {
|
if (this.prevHilight !== null && this.prevHilight !== index) {
|
||||||
for (i = _i = 0, _ref = this.seriesPoints.length - 1; 0 <= _ref ? _i <= _ref : _i >= _ref; i = 0 <= _ref ? ++_i : --_i) {
|
for (i = _i = 0, _ref = this.seriesPoints.length - 1; 0 <= _ref ? _i <= _ref : _i >= _ref; i = 0 <= _ref ? ++_i : --_i) {
|
||||||
if (this.seriesPoints[i][this.prevHilight]) {
|
if (this.seriesPoints[i][this.prevHilight]) {
|
||||||
this.seriesPoints[i][this.prevHilight].animate(this.pointShrink);
|
this.seriesPoints[i][this.prevHilight].animate(this.pointShrinkSeries(index));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (index !== null && this.prevHilight !== index) {
|
if (index !== null && this.prevHilight !== index) {
|
||||||
for (i = _j = 0, _ref1 = this.seriesPoints.length - 1; 0 <= _ref1 ? _j <= _ref1 : _j >= _ref1; i = 0 <= _ref1 ? ++_j : --_j) {
|
for (i = _j = 0, _ref1 = this.seriesPoints.length - 1; 0 <= _ref1 ? _j <= _ref1 : _j >= _ref1; i = 0 <= _ref1 ? ++_j : --_j) {
|
||||||
if (this.seriesPoints[i][index]) {
|
if (this.seriesPoints[i][index]) {
|
||||||
this.seriesPoints[i][index].animate(this.pointGrow);
|
this.seriesPoints[i][index].animate(this.pointGrowSeries(index));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1055,12 +1049,28 @@
|
|||||||
|
|
||||||
Line.prototype.pointSizeForSeries = function(index) {
|
Line.prototype.pointSizeForSeries = function(index) {
|
||||||
if (this.options.pointSize instanceof Array) {
|
if (this.options.pointSize instanceof Array) {
|
||||||
|
console.log(this.options.pointSize);
|
||||||
|
console.log(index);
|
||||||
|
console.log(this.options.pointSize.length);
|
||||||
|
console.log(index % this.options.pointSize.length);
|
||||||
return this.options.pointSize[index % this.options.pointSize.length];
|
return this.options.pointSize[index % this.options.pointSize.length];
|
||||||
} else {
|
} else {
|
||||||
return this.options.pointSize;
|
return this.options.pointSize;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Line.prototype.pointGrowSeries = function(index) {
|
||||||
|
return Raphael.animation({
|
||||||
|
r: this.pointSizeForSeries(index) + 3
|
||||||
|
}, 25, 'linear');
|
||||||
|
};
|
||||||
|
|
||||||
|
Line.prototype.pointShrinkSeries = function(index) {
|
||||||
|
return Raphael.animation({
|
||||||
|
r: this.pointSizeForSeries(index)
|
||||||
|
}, 25, 'linear');
|
||||||
|
};
|
||||||
|
|
||||||
return Line;
|
return Line;
|
||||||
|
|
||||||
})(Morris.Grid);
|
})(Morris.Grid);
|
||||||
|
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