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

Fix graph in cartesian.

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