提交 a7c2f713 编写于 作者: L lang

Line fix after new List

上级 be623cca
......@@ -4,10 +4,6 @@ define(function (require) {
var Group = require('zrender/container/Group');
var symbolCreators = require('../../util/symbol');
function getSymbolElement(dataItem) {
return dataItem.__symbolEl;
}
function createSymbol(data, idx, enableAnimation) {
var point = data.getItemLayout(idx);
var color = data.getItemVisual(idx, 'color');
......@@ -63,10 +59,6 @@ define(function (require) {
return this._data;
},
getSymbolElements: function () {
return this._data.map(getSymbolElement);
},
updateData: function (data, enableAnimation) {
var group = this.group;
......@@ -110,7 +102,7 @@ define(function (require) {
else {
el.attr({
scale: [symbolSize, symbolSize],
position: point
position: point.slice()
});
}
......
......@@ -38,9 +38,10 @@ define(function(require) {
var lineStyleNormalModel = seriesModel.getModel('itemStyle.normal.lineStyle');
var points = data.map(data.getItemLayout, true);
var pointsWithName = data.map(function (dataItem, idx) {
var pointsWithName = data.map(function (idx) {
return {
name: dataItem.name,
// TODO Use category names if possible
name: data.getRawIndex(idx),
point: points[idx]
};
});
......@@ -95,7 +96,7 @@ define(function(require) {
dataSymbol.updateData(data, false);
// In the case data zoom triggerred refreshing frequently
// Data may not change if line has a category axis. So it should animate nothing
if (! isPointsSame(this._pointsWithName, pointsWithName)) {
if (!isPointsSame(this._pointsWithName, pointsWithName)) {
this._updateAnimation(data, pointsWithName);
}
// Add back
......@@ -111,7 +112,6 @@ define(function(require) {
var polyline = this._polyline;
var diff = lineAnimationDiff(this._pointsWithName, pointsWithName);
polyline.shape.points = diff.current;
// FIXME Handle the situation of adding and removing data
polyline.animateTo({
shape: {
points: diff.next
......@@ -120,7 +120,7 @@ define(function(require) {
var updatedDataIndices = [];
var diffStatus = diff.status;
var symbolElements = this._dataSymbol.getSymbolElements();
var data = this._dataSymbol.getData();
for (var i = 0; i < diffStatus.length; i++) {
if (diffStatus[i] === '=') {
......@@ -132,12 +132,13 @@ define(function(require) {
polyline.animators[0].during(function () {
// Symbol elements may be more than updatedDataIndices if there is new added data
for (var i = 0; i < updatedDataIndices.length; i++) {
var el = data.getItemGraphicEl(i);
vector.copy(
symbolElements[i].position,
// synchronizing whith the point on line
el.position,
// synchronizing with the point on line
polyline.shape.points[updatedDataIndices[i]]
);
symbolElements[i].dirty();
el.dirty();
}
});
}
......
......@@ -293,7 +293,7 @@ define(function (require) {
/**
* Get raw data index
*/
listProto.getDataIndex = function (idx) {
listProto.getRawIndex = function (idx) {
return this.indices[idx];
};
......
......@@ -87,17 +87,13 @@ describe('List', function () {
testCase('Data types', function (List) {
var list = new List([{
name: 'name',
type: 'string'
}, {
name: 'x',
type: 'int'
}, {
name: 'y',
type: 'float'
}]);
list.initData([['foo', 1.1, 1.1]]);
expect(list.get('name', 0)).toEqual('foo');
list.initData([[1.1, 1.1]]);
expect(list.get('x', 0)).toEqual(1);
expect(list.get('y', 0)).toBeCloseTo(1.1, 5);
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册