提交 59e77878 编写于 作者: L lang

jshint, markLine 过渡动画调整

上级 ef3ab740
......@@ -144,10 +144,13 @@ option = {
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},
......
......@@ -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) {
......@@ -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);
......@@ -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,
......
......@@ -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];
......@@ -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;
......@@ -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();
}
......
......@@ -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);
......
......@@ -14,7 +14,7 @@ define(function (require) {
this.axis = axis;
this.data = data;
};
}
/**
* @constructor
......@@ -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;
......@@ -241,7 +241,7 @@ define(function (require) {
output.length = found;
return output;
}
};
return KDTree;
});
\ No newline at end of file
......@@ -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++;
......@@ -1195,7 +1195,7 @@ define(function (require) {
{option: magicOption},
self
);
};
}
if (!magicOption.addDataAnimation) {
setTimeout(animationDone, 0);
......
......@@ -34,7 +34,7 @@ define(function (require) {
];
this.group = group;
};
}
function Edge(edge) {
var points = edge.points;
......@@ -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);
}
......@@ -277,7 +278,7 @@ define(function (require) {
groups: groups,
edges: edges,
savedInk: totalSavedInk
}
};
},
_calculateEdgeEdgeInk: (function () {
......@@ -360,7 +361,7 @@ define(function (require) {
this._limitTurningAngle(
endPointSet, cp1, cp0, mp1
);
}
};
})(),
_limitTurningAngle: (function () {
......@@ -408,7 +409,7 @@ define(function (require) {
}
};
})()
}
};
return EdgeBundling;
});
\ No newline at end of file
......@@ -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 {
......
......@@ -256,7 +256,7 @@ define(function (require) {
zr.delShape(effectShape.id);
}
effectShape.effectAnimator = null;
}
};
if (shape instanceof Polyline) {
var distanceList = [0];
......@@ -277,7 +277,7 @@ define(function (require) {
distanceList.push(totalDist);
}
var obj = { p: 0 };
var animator = zr.animation.animate(obj, { loop: effect.loop })
var animator = zr.animation.animate(obj, { loop: effect.loop });
for (var i = 0; i < distanceList.length; i++) {
animator.when(distanceList[i] * effect.period, { p: i });
......@@ -337,7 +337,6 @@ define(function (require) {
if (shape.style.curveness > 0) {
var x1 = shapeStyle.cpX1 - offset;
var y1 = shapeStyle.cpY1 - offset;
var obj = { p: 0 };
effectShape.effectAnimator = zr.animation.animate(effectShape, { loop: effect.loop })
.when(duration, { p: 1 })
.during(function (target, t) {
......@@ -411,7 +410,7 @@ define(function (require) {
for (var i = 0; i < subEffectAnimators.length; i++) {
subEffectAnimators[i].stop();
}
}
};
if (maxDuration) {
effectShape.__dummy = 0;
// Proxy animator
......@@ -432,7 +431,7 @@ define(function (require) {
animator.stop = function () {
clearAllAnimators();
oldStop.call(this);
}
};
}
}
......
......@@ -27,10 +27,8 @@ define(function (require) {
var CurveShape = require('zrender/shape/BezierCurve');
var curveInstance = new CurveShape({});
var matrix = require('zrender/tool/matrix');
var area = require('zrender/tool/area');
var dashedLineTo = require('zrender/shape/util/dashedLineTo');
var smoothSpline = require('zrender/shape/util/smoothSpline');
var zrUtil = require('zrender/tool/util');
var curveTool = require('zrender/tool/curve');
......@@ -90,8 +88,6 @@ define(function (require) {
* @param {Object} style 样式
*/
buildPath : function (ctx, style) {
var lineWidth = style.lineWidth || 1;
var lineType = style.lineType || 'solid';
ctx.moveTo(style.xStart, style.yStart);
......@@ -177,7 +173,7 @@ define(function (require) {
rotate = rotate / 180 * Math.PI;
if (symbol == 'arrow' && rotate === 0) {
if (curveness == 0) {
if (curveness === 0) {
var sign = idx === 0 ? -1 : 1;
rotate = Math.PI / 2 + Math.atan2(
sign * (y2 - y0), sign * (x2 - x0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册