提交 9a5995ed 编写于 作者: L lang

Model#getShallow for optimization

上级 043244eb
......@@ -49,7 +49,7 @@ define(function (require) {
* @return {*}
*/
get: function (path, ignoreParent) {
if (! path) {
if (!path) {
return this.option;
}
......@@ -58,18 +58,34 @@ define(function (require) {
}
var obj = this.option;
var parentModel = this.parentModel;
for (var i = 0; i < path.length; i++) {
obj = obj && obj[path[i]];
if (obj == null) {
break;
}
}
if (obj == null && this.parentModel && !ignoreParent) {
return this.parentModel.get(path);
if (obj == null && parentModel && !ignoreParent) {
obj = parentModel.get(path);
}
return obj;
},
/**
* @param {string} key
* @param {boolean} [ignoreParent=false]
* @return {*}
*/
getShallow: function (key, ignoreParent) {
var option = this.option;
var val = option && option[key];
var parentModel = this.parentModel;
if (val == null && parentModel && !ignoreParent) {
val = parentModel.getShallow(key);
}
return val;
},
/**
* @param {string} path
* @return {module:echarts/model/Model}
......
// TODO Parse shadow style
// TODO Only shallow path support
define(function (require) {
var zrUtil = require('zrender/core/util');
......@@ -16,7 +17,7 @@ define(function (require) {
if (excludes && zrUtil.indexOf(excludes, propName) >= 0) {
continue;
}
var val = this.get(propName);
var val = this.getShallow(propName);
if (val != null) {
style[properties[i][0]] = val;
}
......
......@@ -157,6 +157,11 @@ define(function(require) {
: (doubledPosition + (positiveOrNegative ? 1 : -1)) / 2;
},
/**
* Set hover style of element
* @param {module:zrender/graphic/Displayable} el
* @param {Object} hoverStyle
*/
setHoverStyle: function (el, hoverStyle) {
var stroke = el.style.stroke;
var fill = el.style.fill;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册