提交 8fd367cb 编写于 作者: S sushuang

Fix graph in cartesian.

上级 361b7694
import {each} from 'zrender/src/core/util';
import {simpleLayout, simpleLayoutEdge} from './simpleLayoutHelper';
export default function (ecModel, api) {
......@@ -6,28 +7,30 @@ export default function (ecModel, api) {
var coordSys = seriesModel.coordinateSystem;
if (coordSys && coordSys.type !== 'view') {
var data = seriesModel.getData();
var dimensions = coordSys.dimensions;
data.each(dimensions, function () {
var hasValue;
var args = arguments;
var dimensions = [];
each(coordSys.dimensions, function (coordDim) {
dimensions = dimensions.concat(data.mapDimension(coordDim, true));
});
for (var dataIndex = 0; dataIndex < data.count(); dataIndex++) {
var value = [];
var hasValue = false;
for (var i = 0; i < dimensions.length; i++) {
if (!isNaN(args[i])) {
var val = data.get(dimensions[i], dataIndex);
if (!isNaN(val)) {
hasValue = true;
}
value.push(args[i]);
value.push(val);
}
var idx = args[args.length - 1];
if (hasValue) {
data.setItemLayout(idx, coordSys.dataToPoint(value));
data.setItemLayout(dataIndex, coordSys.dataToPoint(value));
}
else {
// Also {Array.<number>}, not undefined to avoid if...else... statement
data.setItemLayout(idx, [NaN, NaN]);
data.setItemLayout(dataIndex, [NaN, NaN]);
}
});
}
simpleLayoutEdge(data.graph);
}
......
......@@ -35,7 +35,7 @@ export default function (nodes, edges, seriesModel, directed, beforeLink) {
var coordSys = seriesModel.get('coordinateSystem');
var nodeData;
if (coordSys === 'cartesian2d' || coordSys === 'polar') {
nodeData = createListFromArray({data: nodes}, seriesModel);
nodeData = createListFromArray(nodes, seriesModel);
}
else {
// FIXME
......
......@@ -6,12 +6,17 @@ import {getDimensionTypeByAxis} from '../../data/helper/dimensionHelper';
import {getDataItemValue} from '../../util/model';
import CoordinateSystem from '../../CoordinateSystem';
import {getCoordSysDefineBySeries} from '../../model/referHelper';
import Source from '../../data/Source';
/**
* @param {module:echarts/data/Source} source
* @param {module:echarts/data/Source|Array} source Or raw data.
* @param {module:echarts/model/Series} seriesModel
*/
function createListFromArray(source, seriesModel) {
if (!Source.isInstance(source)) {
source = Source.seriesDataToSource(source);
}
var coordSysName = seriesModel.get('coordinateSystem');
var registeredCoordSys = CoordinateSystem.get(coordSysName);
......
......@@ -1651,6 +1651,6 @@ listProto.wrapMethod = function (methodName, injectFunction) {
// Notice that those method should `RETURN` the new list.
listProto.TRANSFERABLE_METHODS = ['cloneShallow', 'downSample', 'map'];
// Methods that change indices of this list should be listed here.
// listProto.CHANGABLE_METHODS = ['filterSelf'];
listProto.CHANGABLE_METHODS = ['filterSelf', 'selectRange'];
export default List;
......@@ -52,9 +52,9 @@ function linkList(opt) {
// Only mainData trigger change, because struct.update may trigger
// another changable methods, which may bring about dead lock.
// each(mainData.CHANGABLE_METHODS, function (methodName) {
// mainData.wrapMethod(methodName, zrUtil.curry(changeInjection, opt));
// });
each(mainData.CHANGABLE_METHODS, function (methodName) {
mainData.wrapMethod(methodName, zrUtil.curry(changeInjection, opt));
});
// Make sure datas contains mainData.
zrUtil.assert(datas[mainData.dataType] === mainData);
......@@ -74,10 +74,10 @@ function transferInjection(opt, res) {
return res;
}
// function changeInjection(opt, res) {
// opt.struct && opt.struct.update(this);
// return res;
// }
function changeInjection(opt, res) {
opt.struct && opt.struct.update(this);
return res;
}
function cloneShallowInjection(opt, res) {
// cloneShallow, which brings about some fragilities, may be inappropriate
......
......@@ -97,7 +97,7 @@ var ComponentModel = Model.extend({
$constructor: function (option, parentModel, ecModel, extraOpt) {
Model.call(this, option, parentModel, ecModel, extraOpt);
this.uid = componentUtil.getUID('componentModel');
this.uid = componentUtil.getUID('ec_cpt_model');
},
init: function (option, parentModel, ecModel, extraOpt) {
......
......@@ -163,7 +163,9 @@ function performStageTasks(scheduler, stageHandlers, ecModel, payload, opt) {
updatePayload(overallTask, payload);
var performArgs = scheduler.getPerformArgs(overallTask, opt.block);
// Execute stubs firstly, which may set the overall task dirty,
// then execute the overall task.
// then execute the overall task. And stub will call seriesModel.setData,
// which ensures that in the overallTask seriesModel.getData() will not
// return incorrect data.
ecModel.eachRawSeries(function (seriesModel) {
var task = agentStubMap.get(seriesModel.uid);
task && task.perform(performArgs);
......
......@@ -11,7 +11,7 @@ var base = 0;
export function getUID(type) {
// Considering the case of crossing js context,
// use Math.random to make id as unique as possible.
return [(type || ''), base++, Math.random()].join('_');
return [(type || ''), base++, Math.random().toFixed(5)].join('_');
}
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册