提交 09608e50 编写于 作者: P pah100

remvoe factory layout. change: component hash by id, not uid.

上级 e098693d
......@@ -535,7 +535,7 @@
this.api.dispatch({
type: 'treemapMove',
from: this.uid,
seriesUID: this.seriesModel.uid,
seriesId: this.seriesModel.getId(),
rootRect: {
x: rootLayout.x + dx, y: rootLayout.y + dy,
width: rootLayout.width, height: rootLayout.height
......@@ -582,7 +582,7 @@
this.api.dispatch({
type: 'treemapRender',
from: this.uid,
seriesUID: this.seriesModel.uid,
seriesId: this.seriesModel.getId(),
rootRect: {
x: rect.x, y: rect.y,
width: rect.width, height: rect.height
......@@ -659,7 +659,7 @@
this.api.dispatch({
type: 'treemapZoomToNode',
from: this.uid,
seriesUID: this.seriesModel.uid,
seriesId: this.seriesModel.getId(),
targetNode: targetInfo.node
});
},
......
......@@ -3,12 +3,12 @@ define(function (require) {
var helper = {
irrelevant: function (payload, seriesModel) {
// It is irrelavant only when seriesUID or seriesName is
// It is irrelavant only when seriesID or seriesName is
// specified and not equals to seriesModel's.
return payload
&& (
payload.seriesUID != null
? seriesModel.uid !== payload.seriesUID
payload.seriesId != null
? seriesModel.getId() !== payload.seriesId
: payload.seriesName != null
// FIXME
// seriesModel.getId() ???
......
......@@ -13,7 +13,7 @@ define(function (require) {
/**
* @public
*/
function layout(ecModel, api, payload) {
function update(ecModel, api, payload) {
// Layout result in each node:
// {x, y, width, height, area, borderWidth}
ecModel.eachSeriesByType('treemap', function (seriesModel) {
......@@ -505,6 +505,5 @@ define(function (require) {
}
}
return layout;
return update;
});
\ No newline at end of file
......@@ -249,7 +249,7 @@ define(function(require) {
this.api.dispatch({
type: 'selectDataRange',
from: this.uid,
dataRangeModelId: this.dataRangeModel.uid,
dataRangeModelId: this.dataRangeModel.getId(),
selected: this._dataInterval.slice()
});
},
......
......@@ -162,7 +162,7 @@ define(function(require) {
this.api.dispatch({
type: 'selectDataRange',
from: this.uid,
dataRangeModelId: this.dataRangeModel.uid,
dataRangeModelId: this.dataRangeModel.getId(),
selected: selected
});
}
......
......@@ -605,7 +605,7 @@ define(function (require) {
this.api.dispatch({
type: 'dataZoom',
from: this.uid,
dataZoomModelId: this.dataZoomModel.uid,
dataZoomModelId: this.dataZoomModel.getId(),
dataZoomRange: this._range.slice()
});
},
......
......@@ -91,15 +91,6 @@ define(function (require) {
* @private
*/
this._coordinateSystem = new CoordinateSystemManager();
/**
* Layout instances
* @type {Array}
* @private
*/
this._layouts = zrUtil.map(layoutClasses, function (Layout) {
return new Layout();
});
};
var echartsProto = ECharts.prototype;
......@@ -282,8 +273,7 @@ define(function (require) {
// Upate all charts
ecModel.eachSeries(function (seriesModel, idx) {
var id = getViewId(seriesModel);
var chart = this._chartsMap[id];
var chart = this._chartsMap[seriesModel.getId()];
chart[methodName](seriesModel, ecModel, api, payload);
updateZ(seriesModel, chart);
......@@ -302,7 +292,7 @@ define(function (require) {
}
ecModel.eachSeries(function (seriesModel, idx) {
var id = getViewId(seriesModel);
var id = seriesModel.getId();
var chart = chartsMap[id];
if (!chart) {
......@@ -353,7 +343,7 @@ define(function (require) {
return;
}
var id = getViewId(componentModel);
var id = componentModel.getId();
var component = componentsMap[id];
if (!component) {
// Create and add component
......@@ -472,8 +462,7 @@ define(function (require) {
// Render all charts
ecModel.eachSeries(function (seriesModel, idx) {
var id = getViewId(seriesModel);
var chart = this._chartsMap[id];
var chart = this._chartsMap[seriesModel.getId()];
chart.__keepAlive = true;
chart.render(seriesModel, ecModel, api, payload);
......@@ -499,14 +488,6 @@ define(function (require) {
this.zr.dispose();
};
/**
* @param {module:echarts/model/Series|module:echarts/model/Component} model
* @return {string}
*/
function getViewId(model) {
return model.name + '_' + model.type;
}
/**
* @param {module:echarts/model/Series|module:echarts/model/Component} model
* @param {module:echarts/view/Component|module:echarts/view/Chart} view
......@@ -527,12 +508,6 @@ define(function (require) {
*/
var actions = [];
/**
* @type {Array.<Function>}
* @inner
*/
var layoutClasses = [];
/**
* @type {Array.<Function>}
* @inner
......@@ -634,15 +609,8 @@ define(function (require) {
*/
echarts.registerLayout = function (layout, isFactory) {
// PENDING All functions ?
if (isFactory) {
if (zrUtil.indexOf(layoutClasses, layout) < 0) {
layoutClasses.push(layout);
}
}
else {
if (zrUtil.indexOf(layoutFuncs, layout) < 0) {
layoutFuncs.push(layout);
}
if (zrUtil.indexOf(layoutFuncs, layout) < 0) {
layoutFuncs.push(layout);
}
};
......
......@@ -78,6 +78,19 @@ define(function(require) {
this.__defaultOption = defaultOption;
}
return this.__defaultOption;
},
/**
* Two ids are different if and only if their component types
* or names are different. We use this id to hash component models
* and view instances in echarts. When setOption are called in
* no-merge mode, new models are able to replace old model, and
* view instances are able to mapped to previous.
* @public
* @return {string} id
*/
getId: function () {
return this.name + '__' + this.type;
}
});
......@@ -88,13 +101,16 @@ define(function(require) {
function (option, parentModel, ecModel, dependentModels, index) {
this.ecModel = ecModel;
this.dependentModels = dependentModels;
this.uid = componentUtil.getUID('componentModel');
// FIXME
// 如果name重复,要进行提示。
var componentName = option.name;
if (componentName == null) {
componentName = this.type + '' + index;
}
this.name = componentName + '';
this.uid = componentUtil.getUID('componentModel');
}
);
......
......@@ -35,13 +35,7 @@ define(function (require) {
this.option = {};
/**
* @type {Array.<module:echarts/model/Model}
* @private
*/
this._components = [];
/**
* @type {Object.<string, module:echarts/model/Model>}
* @type {Object.<string, Array.<module:echarts/model/Model>>}
* @private
*/
this._componentsMap = {};
......@@ -140,7 +134,7 @@ define(function (require) {
var newCptOption = newCptOptionList[i];
var subType = this._determineSubType(
componentType, newCptOption, existComponents[i]
componentType, newCptOption, componentModel
);
var ComponentModelClass = ComponentModel.getClass(
componentType, subType, true
......@@ -158,8 +152,7 @@ define(function (require) {
componentsMap[componentType][i] = componentModel;
// Merge option is incremental
this._components.push(componentModel);
this._componentsIdMap[componentModel.uid] = componentModel;
this._componentsIdMap[componentModel.getId()] = componentModel;
}
}
}
......@@ -237,11 +230,11 @@ define(function (require) {
},
/**
* @param {string} uid
* @param {string} id
* @return {module:echarts/model/Component}
*/
getComponentById: function (uid) {
return this._componentsIdMap[uid];
getComponentById: function (id) {
return this._componentsIdMap[id];
},
/**
......
......@@ -20,17 +20,6 @@ define(function(require) {
return [(type || ''), base++, Math.random()].join(DELIMITER);
};
/**
* @public
* @param {string} uid
* @return {string} Type
*/
util.getUIDType = function (uid) {
if (uid) {
return uid.split(DELIMITER)[0];
}
};
/**
* @public
*/
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册