Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
alon@wen
echarts
提交
63eb7b5b
E
echarts
项目概览
alon@wen
/
echarts
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
echarts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
63eb7b5b
编写于
9月 24, 2015
作者:
P
pah100
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change mergeoption, mapping
上级
e712f352
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
89 addition
and
57 deletion
+89
-57
src/echarts.js
src/echarts.js
+7
-11
src/model/Component.js
src/model/Component.js
+17
-29
src/model/Global.js
src/model/Global.js
+55
-9
src/util/component.js
src/util/component.js
+9
-7
src/view/Chart.js
src/view/Chart.js
+1
-1
未找到文件。
src/echarts.js
浏览文件 @
63eb7b5b
...
...
@@ -23,12 +23,6 @@ define(function (require) {
var
VISUAL_CODING_STAGES
=
[
'
echarts
'
,
'
chart
'
,
'
component
'
];
/**
* @inner
*/
function
getSeriesId
(
series
,
seriesIndex
)
{
return
series
.
type
+
'
_
'
+
(
series
.
name
||
seriesIndex
);
}
/**
* @module echarts~ECharts
*/
...
...
@@ -231,7 +225,7 @@ define(function (require) {
}
ecModel
.
eachSeries
(
function
(
seriesModel
,
idx
)
{
var
id
=
getSeriesId
(
seriesModel
.
option
,
idx
)
;
var
id
=
seriesModel
.
uid
;
var
chart
=
chartsMap
[
id
];
if
(
!
chart
)
{
...
...
@@ -277,16 +271,18 @@ define(function (require) {
componentsList
[
i
].
__keepAlive
=
true
;
}
ecModel
.
eachComponent
(
function
(
componentType
,
componentModel
,
idx
)
{
ecModel
.
eachComponent
(
function
(
componentType
,
componentModel
)
{
if
(
componentType
===
'
series
'
)
{
return
;
}
var
id
=
component
Type
+
'
_
'
+
idx
;
var
id
=
component
Model
.
uid
;
var
component
=
componentsMap
[
id
];
if
(
!
component
)
{
// Create and add component
var
Clazz
=
ComponentView
.
getClass
(
componentType
,
componentModel
.
option
);
var
Clazz
=
ComponentView
.
getClass
(
componentType
,
componentModel
.
option
.
type
);
if
(
Clazz
)
{
component
=
new
Clazz
();
...
...
@@ -392,7 +388,7 @@ define(function (require) {
// Render all charts
ecModel
.
eachSeries
(
function
(
seriesModel
,
idx
)
{
var
id
=
getSeriesId
(
seriesModel
.
option
,
idx
)
;
var
id
=
seriesModel
.
uid
;
var
chart
=
this
.
_chartsMap
[
id
];
chart
.
__keepAlive
=
true
;
chart
.
render
(
seriesModel
,
ecModel
,
api
,
event
);
...
...
src/model/Component.js
浏览文件 @
63eb7b5b
...
...
@@ -5,8 +5,6 @@
*/
define
(
function
(
require
)
{
'
use strict
'
;
var
Model
=
require
(
'
./Model
'
);
var
zrUtil
=
require
(
'
zrender/core/util
'
);
var
arrayPush
=
Array
.
prototype
.
push
;
...
...
@@ -30,7 +28,7 @@ define(function(require) {
defaultOption
:
null
,
/**
* @type {
Object
}
* @type {
module:echarts/model/Global
}
* @readOnly
*/
ecModel
:
null
,
...
...
@@ -41,7 +39,13 @@ define(function(require) {
* @type {Object.<string, Array.<module:echarts/model/Model>>}
* @readOnly
*/
dependentModel
:
null
,
dependentModels
:
null
,
/**
* @type {string}
* @readOnly
*/
uid
:
null
,
init
:
function
()
{
this
.
mergeDefaultAndTheme
(
this
.
option
,
this
.
ecModel
);
...
...
@@ -73,35 +77,19 @@ define(function(require) {
});
ComponentModel
.
extend
=
function
(
proto
)
{
var
SubComponentModel
=
function
(
option
,
parentModel
,
ecModel
,
dependentModels
)
{
this
.
ecModel
=
ecModel
;
this
.
dependentModels
=
dependentModels
;
/**
* @type {string}
* @public
* @readOnly
*/
this
.
uid
=
componentUtil
.
getUID
(
'
componentModel
'
);
ComponentModel
.
apply
(
this
,
arguments
);
};
zrUtil
.
extend
(
SubComponentModel
.
prototype
,
proto
);
var
Super
=
this
;
SubComponentModel
.
extend
=
Super
.
extend
;
zrUtil
.
inherits
(
SubComponentModel
,
Super
);
return
SubComponentModel
;
};
// Reset ComponentModel.extend, add preConstruct.
componentUtil
.
enableClassExtend
(
ComponentModel
,
function
(
option
,
parentModel
,
ecModel
,
dependentModels
)
{
this
.
ecModel
=
ecModel
;
this
.
dependentModels
=
dependentModels
;
this
.
uid
=
componentUtil
.
getUID
(
'
componentModel
'
);
});
// A
n
d capability of registerClass, getClass, hasClass, registerSubTypeDefaulter and so on.
// A
d
d capability of registerClass, getClass, hasClass, registerSubTypeDefaulter and so on.
componentUtil
.
enableClassManagement
(
ComponentModel
,
{
subTypeDefaulter
:
true
,
registerWhenExtend
:
true
}
ComponentModel
,
{
subTypeDefaulter
:
true
,
registerWhenExtend
:
true
}
);
// Add capability of ComponentModel.topologicalTravel.
componentUtil
.
enableTopologicalTravel
(
ComponentModel
,
getDependencies
);
function
getDependencies
(
componentType
)
{
...
...
src/model/Global.js
浏览文件 @
63eb7b5b
...
...
@@ -119,32 +119,36 @@ define(function (require) {
// FIXME 这里 componentTypes 是新的 Option,在依赖处理上是否会有问题
// FIXME OPTION 同步是否要改回原来的
ComponentModel
.
topologicalTravel
(
componentTypes
,
function
(
componentType
,
dependencies
)
{
var
componentOption
=
newOption
[
componentType
];
var
newCptOptionList
=
newOption
[
componentType
];
// Normalize
if
(
!
(
zrUtil
.
isArray
(
componentOption
)))
{
componentOption
=
[
componentOption
];
if
(
!
(
zrUtil
.
isArray
(
newCptOptionList
)))
{
newCptOptionList
=
[
newCptOptionList
];
}
if
(
!
componentsMap
[
componentType
])
{
componentsMap
[
componentType
]
=
[];
}
for
(
var
i
=
0
;
i
<
componentOption
.
length
;
i
++
)
{
var
componentModel
=
componentsMap
[
componentType
][
i
];
var
existComponents
=
this
.
_mappingToExists
(
componentType
,
newCptOptionList
);
ComponentModel
.
completeSubType
(
componentType
,
componentOption
[
i
]);
for
(
var
i
=
0
;
i
<
newCptOptionList
.
length
;
i
++
)
{
var
componentModel
=
existComponents
[
i
];
var
newCptOption
=
newCptOptionList
[
i
];
var
subType
=
this
.
_determineSubType
(
componentType
,
newCptOption
,
existComponents
[
i
]
);
var
ComponentModelClass
=
ComponentModel
.
getClass
(
componentType
,
componentOption
[
i
]
,
true
componentType
,
subType
,
true
);
if
(
componentModel
&&
componentModel
instanceof
ComponentModelClass
)
{
componentModel
.
mergeOption
(
componentOption
[
i
]
,
this
);
componentModel
.
mergeOption
(
newCptOption
,
this
);
}
else
{
// PENDING Global as parent ?
componentModel
=
new
ComponentModelClass
(
componentOption
[
i
],
this
,
this
,
newCptOptionList
[
i
],
this
,
this
,
this
.
_getComponentsByTypes
(
dependencies
),
i
);
componentsMap
[
componentType
][
i
]
=
componentModel
;
...
...
@@ -162,6 +166,48 @@ define(function (require) {
},
this
);
},
/**
* @private
*/
_determineSubType
:
function
(
componentType
,
newCptOption
,
existComponent
)
{
return
newCptOption
.
type
?
newCptOption
.
type
:
existComponent
?
existComponent
.
option
.
type
// Use determinSubType only when there is no existComponent.
:
ComponentModel
.
determineSubType
(
componentType
,
newCptOption
);
},
/**
* @private
*/
_mappingToExists
:
function
(
componentType
,
newComponentOptionList
)
{
var
result
=
[];
var
existComponents
=
(
this
.
_componentsMap
[
componentType
]
||
[]).
slice
();
// Mapping by name if specified.
zrUtil
.
each
(
newComponentOptionList
,
function
(
componentOption
,
index
)
{
if
(
!
componentOption
.
name
)
{
return
;
}
for
(
var
i
=
0
,
len
=
existComponents
.
length
;
i
<
len
;
i
++
)
{
if
(
existComponents
[
i
].
name
===
componentOption
.
name
)
{
result
[
index
]
=
existComponents
.
splice
(
i
,
1
)[
0
];
break
;
}
}
});
// Otherwise mapping by index.
zrUtil
.
each
(
newComponentOptionList
,
function
(
componentOption
,
index
)
{
if
(
!
result
[
index
])
{
result
[
index
]
=
existComponents
[
index
];
}
});
return
result
;
},
/**
* @return {module:echarts/model/Model}
*/
...
...
src/util/component.js
浏览文件 @
63eb7b5b
...
...
@@ -47,9 +47,10 @@ define(function(require) {
/**
* @public
*/
util
.
enableClassExtend
=
function
(
RootClass
)
{
util
.
enableClassExtend
=
function
(
RootClass
,
preConstruct
)
{
RootClass
.
extend
=
function
(
proto
)
{
var
ExtendedClass
=
function
()
{
preConstruct
&&
preConstruct
.
apply
(
this
,
arguments
);
RootClass
.
apply
(
this
,
arguments
);
};
...
...
@@ -99,12 +100,11 @@ define(function(require) {
return
Clazz
;
};
entity
.
getClass
=
function
(
componentTypeMain
,
option
,
throwWhenNotFound
)
{
entity
.
getClass
=
function
(
componentTypeMain
,
subType
,
throwWhenNotFound
)
{
var
Clazz
=
storage
[
componentTypeMain
];
var
subType
=
option
&&
option
.
type
;
if
(
Clazz
&&
Clazz
[
IS_CONTAINER
]
&&
subType
)
{
Clazz
=
Clazz
[
subType
]
;
if
(
Clazz
&&
Clazz
[
IS_CONTAINER
])
{
Clazz
=
subType
?
Clazz
[
subType
]
:
null
;
}
if
(
throwWhenNotFound
&&
!
Clazz
)
{
...
...
@@ -182,8 +182,9 @@ define(function(require) {
subTypeDefaulters
[
componentType
.
main
]
=
defaulter
;
};
entity
.
completeSubType
=
function
(
componentType
,
option
)
{
if
(
!
option
.
type
)
{
entity
.
determineSubType
=
function
(
componentType
,
option
)
{
var
type
=
option
.
type
;
if
(
!
type
)
{
var
componentTypeMain
=
parseComponentType
(
componentType
).
main
;
var
Clazz
=
storage
[
componentTypeMain
];
Clazz
...
...
@@ -191,6 +192,7 @@ define(function(require) {
&&
subTypeDefaulters
[
componentTypeMain
]
&&
subTypeDefaulters
[
componentTypeMain
](
option
);
}
return
type
;
};
return
entity
;
...
...
src/view/Chart.js
浏览文件 @
63eb7b5b
...
...
@@ -37,7 +37,7 @@ define(function (require) {
// Enable Chart.extend.
componentUtil
.
enableClassExtend
(
Chart
);
// A
n
d capability of registerClass, getClass, hasClass, registerSubTypeDefaulter and so on.
// A
d
d capability of registerClass, getClass, hasClass, registerSubTypeDefaulter and so on.
componentUtil
.
enableClassManagement
(
Chart
,
{
registerWhenExtend
:
true
});
return
Chart
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录