Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
半栈学徒
incubator-echarts
提交
221e4ca5
I
incubator-echarts
项目概览
半栈学徒
/
incubator-echarts
与 Fork 源项目一致
从无法访问的项目Fork
通知
5
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
incubator-echarts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
221e4ca5
编写于
2月 03, 2016
作者:
L
lang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Optimize Model construction, getItemModel always return new
上级
91aead28
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
28 addition
and
33 deletion
+28
-33
src/component/marker/MarkLineModel.js
src/component/marker/MarkLineModel.js
+5
-4
src/component/marker/MarkPointModel.js
src/component/marker/MarkPointModel.js
+5
-4
src/data/List.js
src/data/List.js
+4
-20
src/model/Model.js
src/model/Model.js
+14
-5
未找到文件。
src/component/marker/MarkLineModel.js
浏览文件 @
221e4ca5
...
...
@@ -15,9 +15,9 @@ define(function (require) {
/**
* @overrite
*/
init
:
function
(
option
,
parentModel
,
ecModel
,
extraOpt
,
createdBySelf
)
{
init
:
function
(
option
,
parentModel
,
ecModel
,
extraOpt
)
{
this
.
mergeDefaultAndTheme
(
option
,
ecModel
);
this
.
mergeOption
(
option
,
ecModel
,
createdBySelf
,
true
);
this
.
mergeOption
(
option
,
ecModel
,
extraOpt
.
createdBySelf
,
true
);
},
mergeOption
:
function
(
newOpt
,
ecModel
,
createdBySelf
,
isInit
)
{
...
...
@@ -40,10 +40,11 @@ define(function (require) {
var
opt
=
{
// Use the same series index and name
seriesIndex
:
seriesModel
.
seriesIndex
,
name
:
seriesModel
.
name
name
:
seriesModel
.
name
,
createdBySelf
:
true
};
mlModel
=
new
MarkLineModel
(
markLineOpt
,
this
,
ecModel
,
opt
,
true
markLineOpt
,
this
,
ecModel
,
opt
);
}
else
{
...
...
src/component/marker/MarkPointModel.js
浏览文件 @
221e4ca5
...
...
@@ -13,9 +13,9 @@ define(function (require) {
/**
* @overrite
*/
init
:
function
(
option
,
parentModel
,
ecModel
,
extraOpt
,
createdBySelf
)
{
init
:
function
(
option
,
parentModel
,
ecModel
,
extraOpt
)
{
this
.
mergeDefaultAndTheme
(
option
,
ecModel
);
this
.
mergeOption
(
option
,
ecModel
,
createdBySelf
,
true
);
this
.
mergeOption
(
option
,
ecModel
,
extraOpt
.
createdBySelf
,
true
);
},
mergeOption
:
function
(
newOpt
,
ecModel
,
createdBySelf
,
isInit
)
{
...
...
@@ -38,10 +38,11 @@ define(function (require) {
var
opt
=
{
// Use the same series index and name
seriesIndex
:
seriesModel
.
seriesIndex
,
name
:
seriesModel
.
name
name
:
seriesModel
.
name
,
createdBySelf
:
true
};
mpModel
=
new
MarkPointModel
(
markPointOpt
,
this
,
ecModel
,
opt
,
true
markPointOpt
,
this
,
ecModel
,
opt
);
}
else
{
...
...
src/data/List.js
浏览文件 @
221e4ca5
...
...
@@ -723,7 +723,6 @@ define(function (require) {
return
list
;
};
var
temporaryModel
=
new
Model
(
null
);
// Since temporate model is shared by all data items. So we must make sure it can't be write.
// PENDING may cause any performance problem?
// if (Object.freeze) {
...
...
@@ -731,29 +730,14 @@ define(function (require) {
// }
/**
* Get model of one data item.
* It will create a temporary model if value on idx is not an option.
*
* @param {number} idx
* @param {boolean} [createNew=false]
*/
// FIXME Model proxy ?
listProto
.
getItemModel
=
function
(
idx
,
createNew
)
{
var
model
;
listProto
.
getItemModel
=
function
(
idx
)
{
var
hostModel
=
this
.
hostModel
;
idx
=
this
.
indices
[
idx
];
// Use a temporary model proxy
// FIXME Create a new one may cause memory leak
if
(
createNew
)
{
model
=
new
Model
(
null
,
hostModel
);
}
else
{
model
=
temporaryModel
;
}
// FIXME If return null when idx not exists
model
.
option
=
this
.
_rawData
[
idx
];
model
.
parentModel
=
hostModel
;
model
.
ecModel
=
hostModel
.
ecModel
;
return
model
;
return
new
Model
(
this
.
_rawData
[
idx
],
hostModel
,
hostModel
.
ecModel
);
};
/**
...
...
@@ -807,7 +791,7 @@ define(function (require) {
/**
* Set layout property.
* @param {string} key
* @param {string} key
* @param {*} val
*/
listProto
.
setLayout
=
function
(
key
,
val
)
{
...
...
@@ -819,7 +803,7 @@ define(function (require) {
* @param {string} key.
* @return {*}
*/
listProto
.
getLayout
=
function
(
key
)
{
listProto
.
getLayout
=
function
(
key
)
{
return
this
.
_layout
[
key
];
};
...
...
src/model/Model.js
浏览文件 @
221e4ca5
...
...
@@ -12,19 +12,20 @@ define(function (require) {
* @param {Object} option
* @param {module:echarts/model/Model} parentModel
* @param {module:echarts/model/Global} ecModel
* @param {Object} extraOpt
*/
function
Model
(
option
,
parentModel
,
ecModel
)
{
function
Model
(
option
,
parentModel
,
ecModel
,
extraOpt
)
{
/**
* @type {module:echarts/model/Model}
* @readOnly
*/
this
.
parentModel
=
parentModel
||
null
;
this
.
parentModel
=
parentModel
;
/**
* @type {module:echarts/model/Global}
* @readOnly
*/
this
.
ecModel
=
ecModel
||
null
;
this
.
ecModel
=
ecModel
;
/**
* @type {Object}
...
...
@@ -32,7 +33,15 @@ define(function (require) {
*/
this
.
option
=
option
;
this
.
init
.
apply
(
this
,
arguments
);
// Simple optimization
if
(
this
.
init
)
{
if
(
arguments
.
length
<=
4
)
{
this
.
init
(
option
,
parentModel
,
ecModel
,
extraOpt
);
}
else
{
this
.
init
.
apply
(
this
,
arguments
);
}
}
}
Model
.
prototype
=
{
...
...
@@ -43,7 +52,7 @@ define(function (require) {
* Model 的初始化函数
* @param {Object} option
*/
init
:
function
(
option
)
{}
,
init
:
null
,
/**
* 从新的 Option merge
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录