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

Model#getShallow for optimization

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