Skip to content

Commit

Permalink
jshint, markLine 过渡动画调整
Browse files Browse the repository at this point in the history
  • Loading branch information
pissang committed Mar 12, 2015
1 parent ef3ab74 commit 59e7787
Show file tree
Hide file tree
Showing 10 changed files with 106 additions and 130 deletions.
7 changes: 5 additions & 2 deletions doc/example/force.html
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,13 @@
links : [
{source : '丽萨-乔布斯', target : '乔布斯', weight : 1, name: '女儿', itemStyle: {
normal: {
width: 1.5
width: 1.5,
color: 'red'
}
}},
{source : '乔布斯', target : '丽萨-乔布斯', weight : 1, name: '父亲'},
{source : '乔布斯', target : '丽萨-乔布斯', weight : 1, name: '父亲', itemStyle: {
normal: { color: 'red' }
}},
{source : '保罗-乔布斯', target : '乔布斯', weight : 2, name: '父亲'},
{source : '克拉拉-乔布斯', target : '乔布斯', weight : 1, name: '母亲'},
{source : '劳伦-鲍威尔', target : '乔布斯', weight : 2},
Expand Down
5 changes: 3 additions & 2 deletions src/chart/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ define(function (require) {

// Some utility functions
function isCoordAvailable(coord) {
return coord.x != null && coord.y != null
return coord.x != null && coord.y != null;
}

function Base(ecTheme, messageCenter, zr, option, myChart) {
Expand Down Expand Up @@ -915,9 +915,9 @@ define(function (require) {
) {
// 组装一个mergeData
var mergeData = this.deepMerge(mlData);
var value = mergeData.value != null ? mergeData.value : '';
var queryTarget = [mergeData, mlOption];
var color = defaultColor;
var value = mergeData.value != null ? mergeData.value : '';
// 值域
if (dataRange) {
color = isNaN(value) ? color : dataRange.getColor(value);
Expand Down Expand Up @@ -969,6 +969,7 @@ define(function (require) {
var edge = edges[i];
var rawEdge = edge.rawEdge || edge;
var mlData = rawEdge.rawData;
var value = mlData.value != null ? mlData.value : '';

var itemShape = this.getMarkLineShape(
mlOption,
Expand Down
10 changes: 5 additions & 5 deletions src/chart/line.js
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,6 @@ define(function (require) {
*/
addDataAnimation: function (params, done) {
var series = this.series;
var self = this;
var aniMap = {}; // seriesIndex索引参数
for (var i = 0, l = params.length; i < l; i++) {
aniMap[params[i][0]] = params[i];
Expand All @@ -832,6 +831,10 @@ define(function (require) {
done && done();
}
}
function animationDuring(target) {
// 强制更新曲线控制点
target.style.controlPointList = null;
}

for (var i = this.shapeList.length - 1; i >= 0; i--) {
seriesIndex = this.shapeList[i]._seriesIndex;
Expand Down Expand Up @@ -900,10 +903,7 @@ define(function (require) {
this.query(this.option, 'animationDurationUpdate'),
{ position: [ x, y ] }
)
.during(function (target) {
// 强制更新曲线控制点
target.style.controlPointList = null;
})
.during(animationDuring)
.done(animationDone)
.start();
}
Expand Down
90 changes: 45 additions & 45 deletions src/chart/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -1165,53 +1165,53 @@ define(function (require) {
var shapeStyle = shape.style;
shape.position[0] = transform.left;
shape.position[1] = transform.top;
if (shapeType == 'path'
|| shapeType == 'symbol'
|| shapeType == 'circle'
|| shapeType == 'rectangle'
|| shapeType == 'polygon'
|| shapeType == 'line'
|| shapeType == 'ellipse'
) {
shape.scale[0] *= delta;
shape.scale[1] *= delta;
}
else if (shapeType == 'mark-line') {
scaleMarkline(shapeStyle, delta);
}
else if (shapeType == 'polyline') {
scalePolyline(shapeStyle, delta);
}
else if (shapeType == 'shape-bundle') {
for (var j = 0; j < shapeStyle.shapeList.length; j++) {
var subShape = shapeStyle.shapeList[j];
if (subShape.type == 'mark-line') {
scaleMarkline(subShape.style, delta);

switch (shapeType) {
case 'path':
case 'symbol':
case 'circle':
case 'rectangle':
case 'polygon':
case 'line':
case 'ellipse':
shape.scale[0] *= delta;
shape.scale[1] *= delta;
break;
case 'mark-line':
scaleMarkline(shapeStyle, delta);
break;
case 'polyline':
scalePolyline(shapeStyle, delta);
break;
case 'shape-bundle':
for (var j = 0; j < shapeStyle.shapeList.length; j++) {
var subShape = shapeStyle.shapeList[j];
if (subShape.type == 'mark-line') {
scaleMarkline(subShape.style, delta);
}
else if (subShape.type == 'polyline') {
scalePolyline(subShape.style, delta);
}
}
else if (subShape.type == 'polyline') {
scalePolyline(subShape.style, delta);
break;
case 'icon':
case 'image':
geoAndPos = this.geo2pos(mapType, shape._geo);
shapeStyle.x = shapeStyle._x =
geoAndPos[0] - shapeStyle.width / 2;
shapeStyle.y = shapeStyle._y =
geoAndPos[1] - shapeStyle.height / 2;
break;
default:
geoAndPos = this.geo2pos(mapType, shape._geo);
shapeStyle.x = geoAndPos[0];
shapeStyle.y = geoAndPos[1];
if (shapeType == 'text') {
shape._style.x = shape.highlightStyle.x
= geoAndPos[0];
shape._style.y = shape.highlightStyle.y
= geoAndPos[1];
}
}
}
else if (shapeType == 'icon'
|| shapeType == 'image'
) {
geoAndPos = this.geo2pos(mapType, shape._geo);
shapeStyle.x = shapeStyle._x =
geoAndPos[0] - shapeStyle.width / 2;
shapeStyle.y = shapeStyle._y =
geoAndPos[1] - shapeStyle.height / 2;
}
else {
geoAndPos = this.geo2pos(mapType, shape._geo);
shapeStyle.x = geoAndPos[0];
shapeStyle.y = geoAndPos[1];
if (shapeType == 'text') {
shape._style.x = shape.highlightStyle.x
= geoAndPos[0];
shape._style.y = shape.highlightStyle.y
= geoAndPos[1];
}
}

this.zr.modShape(shape.id);
Expand Down
6 changes: 3 additions & 3 deletions src/data/KDTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ define(function (require) {
this.axis = axis;

this.data = data;
};
}

/**
* @constructor
Expand Down Expand Up @@ -174,7 +174,7 @@ define(function (require) {
for (var i = 0; i < N; i++) {
// Allocate
if (!nearestNList[i]) {
nearestNList[i] = {}
nearestNList[i] = {};
}
nearestNList[i].dist = 0;
nearestNList[i].node = null;
Expand Down Expand Up @@ -241,7 +241,7 @@ define(function (require) {
output.length = found;

return output;
}
};

return KDTree;
});
4 changes: 2 additions & 2 deletions src/echarts.js
Original file line number Diff line number Diff line change
Expand Up @@ -1166,7 +1166,7 @@ define(function (require) {
if (chartAnimationCount === 0) {
animationDone();
}
}
};
for (var i = 0, l = chartList.length; i < l; i++) {
if (magicOption.addDataAnimation && chartList[i].addDataAnimation) {
chartAnimationCount++;
Expand Down Expand Up @@ -1195,7 +1195,7 @@ define(function (require) {
{option: magicOption},
self
);
};
}

if (!magicOption.addDataAnimation) {
setTimeout(animationDone, 0);
Expand Down
11 changes: 6 additions & 5 deletions src/layout/EdgeBundling.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ define(function (require) {
];

this.group = group;
};
}

function Edge(edge) {
var points = edge.points;
Expand Down Expand Up @@ -251,8 +251,9 @@ define(function (require) {
}
if (mostSavingInkEdge) {
totalSavedInk += maxSavedInk;
var group;
if (! mostSavingInkEdge.group) {
var group = new BundledEdgeGroup();
group = new BundledEdgeGroup();
groups.push(group);
group.addEdge(mostSavingInkEdge);
}
Expand All @@ -277,7 +278,7 @@ define(function (require) {
groups: groups,
edges: edges,
savedInk: totalSavedInk
}
};
},

_calculateEdgeEdgeInk: (function () {
Expand Down Expand Up @@ -360,7 +361,7 @@ define(function (require) {
this._limitTurningAngle(
endPointSet, cp1, cp0, mp1
);
}
};
})(),

_limitTurningAngle: (function () {
Expand Down Expand Up @@ -408,7 +409,7 @@ define(function (require) {
}
};
})()
}
};

return EdgeBundling;
});
88 changes: 32 additions & 56 deletions src/util/ecAnimation.js
Original file line number Diff line number Diff line change
Expand Up @@ -564,71 +564,47 @@ define(function (require) {

var animationDone = function () {
newShape.__animating = false;
};
var x0 = newShapeStyle.xStart;
var y0 = newShapeStyle.yStart;
var x2 = newShapeStyle.xEnd;
var y2 = newShapeStyle.yEnd;
if (newShapeStyle.curveness > 0) {
newShape.updatePoints(newShapeStyle);
var obj = { p: 0 };
var x1 = newShapeStyle.cpX1;
var y1 = newShapeStyle.cpY1;
var newXArr = [];
var newYArr = [];
var subdivide = curveTool.quadraticSubdivide;
zr.animation.animate(obj)
.when(duration, { p: 1 })
.during(function () {
// Calculate subdivided curve
subdivide(x0, x1, x2, obj.p, newXArr);
subdivide(y0, y1, y2, obj.p, newYArr);
newShapeStyle.cpX1 = newXArr[1];
newShapeStyle.cpY1 = newYArr[1];
newShapeStyle.xEnd = newXArr[2];
newShapeStyle.yEnd = newYArr[2];
zr.modShape(newShape);
})
.done(animationDone)
.start(easing);
}
if (oldShape) {
var oldShapeStyle = oldShape.style;
else {
zr.animate(newShape.id, 'style')
.when(0, {
xStart: oldShapeStyle.xStart,
yStart: oldShapeStyle.yStart,
xEnd: oldShapeStyle.xEnd,
yEnd: oldShapeStyle.yEnd,
cpX1: oldShapeStyle.cpX1 || 0,
cpY1: oldShapeStyle.cpY1 || 0
xEnd: x0,
yEnd: y0
})
.when(duration, {
xStart: newShapeStyle.xStart,
yStart: newShapeStyle.yStart,
xEnd: newShapeStyle.xEnd,
yEnd: newShapeStyle.yEnd,
cpX1: newShapeStyle.cpX1 || 0,
cpY1: newShapeStyle.cpY1 || 0
xEnd: x2,
yEnd: y2
})
.done(animationDone)
.start(easing);
}
else {
var x0 = newShapeStyle.xStart;
var y0 = newShapeStyle.yStart;
var x2 = newShapeStyle.xEnd;
var y2 = newShapeStyle.yEnd;
if (newShapeStyle.curveness > 0) {
newShape.updatePoints(newShapeStyle);
var obj = { p: 0 };
var x1 = newShapeStyle.cpX1;
var y1 = newShapeStyle.cpY1;
var newXArr = [];
var newYArr = [];
var subdivide = curveTool.quadraticSubdivide;
zr.animation.animate(obj)
.when(duration, { p: 1 })
.during(function () {
// Calculate subdivided curve
subdivide(x0, x1, x2, obj.p, newXArr);
subdivide(y0, y1, y2, obj.p, newYArr);
newShapeStyle.cpX1 = newXArr[1];
newShapeStyle.cpY1 = newYArr[1];
newShapeStyle.xEnd = newXArr[2];
newShapeStyle.yEnd = newYArr[2];
zr.modShape(newShape);
})
.done(animationDone)
.start(easing);
}
else {
zr.animate(newShape.id, 'style')
.when(0, {
xEnd: x0,
yEnd: y0
})
.when(duration, {
xEnd: x2,
yEnd: y2
})
.done(animationDone)
.start(easing);
}
}
}

return {
Expand Down
Loading

0 comments on commit 59e7787

Please sign in to comment.