Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
x649585723
incubator-echarts
提交
927d6315
I
incubator-echarts
项目概览
x649585723
/
incubator-echarts
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
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 搜索 >>
提交
927d6315
编写于
12月 26, 2015
作者:
P
pah100
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add reset option
上级
352197d3
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
143 addition
and
80 deletion
+143
-80
src/component/timeline/timelineAction.js
src/component/timeline/timelineAction.js
+3
-1
src/echarts.js
src/echarts.js
+11
-40
src/model/Global.js
src/model/Global.js
+60
-20
src/model/OptionManager.js
src/model/OptionManager.js
+69
-19
未找到文件。
src/component/timeline/timelineAction.js
浏览文件 @
927d6315
...
...
@@ -7,7 +7,7 @@ define(function(require) {
echarts
.
registerAction
(
{
type
:
'
timelineChange
'
,
event
:
'
timelineChanged
'
,
update
:
'
reoption
'
},
{
type
:
'
timelineChange
'
,
event
:
'
timelineChanged
'
,
update
:
'
prepareAndUpdate
'
},
function
(
payload
,
ecModel
)
{
...
...
@@ -19,6 +19,8 @@ define(function(require) {
timelineModel
.
setPlayState
(
false
);
}
}
ecModel
.
updateTimelineOption
();
}
);
...
...
src/echarts.js
浏览文件 @
927d6315
...
...
@@ -14,7 +14,6 @@
define
(
function
(
require
)
{
var
GlobalModel
=
require
(
'
./model/Global
'
);
var
OptionManager
=
require
(
'
./model/OptionManager
'
);
var
ExtensionAPI
=
require
(
'
./ExtensionAPI
'
);
var
CoordinateSystemManager
=
require
(
'
./CoordinateSystem
'
);
...
...
@@ -85,11 +84,6 @@ define(function (require) {
*/
this
.
_theme
=
zrUtil
.
clone
(
theme
,
true
);
/**
* @type {module:echarts/model/OptionManager}
*/
this
.
_optionManager
=
new
OptionManager
();
/**
* @type {Array.<module:echarts/view/Chart>}
* @private
...
...
@@ -163,40 +157,18 @@ define(function (require) {
* @param {boolean} [notRefreshImmediately=false] Useful when setOption frequently.
*/
echartsProto
.
setOption
=
function
(
option
,
notMerge
,
notRefreshImmediately
)
{
var
baseOption
=
this
.
_optionManager
.
updateRawOption
(
option
,
optionPreprocessorFuncs
);
(
!
this
.
_model
||
notMerge
)
?
(
this
.
_model
=
new
GlobalModel
(
baseOption
,
null
,
this
.
_theme
))
:
ecModelMerge
.
call
(
this
,
baseOption
);
var
partialOption
=
this
.
_optionManager
.
getPartialOption
(
this
.
_model
);
if
(
partialOption
)
{
ecModelMerge
.
call
(
this
,
partialOption
);
if
(
!
this
.
_model
||
notMerge
)
{
this
.
_model
=
new
GlobalModel
(
null
,
null
,
this
.
_theme
,
optionPreprocessorFuncs
);
}
prepareAndUpdate
.
call
(
this
);
this
.
_model
.
setOption
(
option
);
updateMethods
.
prepareAndUpdate
.
call
(
this
);
!
notRefreshImmediately
&&
this
.
_zr
.
refreshImmediately
();
};
function
ecModelMerge
(
option
)
{
var
ecModel
=
this
.
_model
;
ecModel
.
restoreData
();
ecModel
.
mergeOption
(
option
);
}
function
prepareAndUpdate
(
payload
)
{
var
ecModel
=
this
.
_model
;
prepareView
.
call
(
this
,
'
component
'
,
ecModel
);
prepareView
.
call
(
this
,
'
chart
'
,
ecModel
);
updateMethods
.
update
.
call
(
this
,
payload
);
}
/**
* @DEPRECATED
*/
...
...
@@ -456,17 +428,16 @@ define(function (require) {
/**
* @param {Object} payload
* @private
*/
reoption
:
function
(
payload
)
{
prepareAndUpdate
:
function
(
payload
)
{
var
ecModel
=
this
.
_model
;
var
optionManager
=
this
.
_optionManager
;
var
partialOption
=
optionManager
.
getPartialOption
(
ecModel
);
if
(
partialOption
)
{
ecModelMerge
.
call
(
this
,
partialOption
);
}
prepareView
.
call
(
this
,
'
component
'
,
ecModel
);
prepareView
.
call
(
this
,
'
chart
'
,
ecModel
);
prepareAndU
pdate
.
call
(
this
,
payload
);
updateMethods
.
u
pdate
.
call
(
this
,
payload
);
}
};
...
...
src/model/Global.js
浏览文件 @
927d6315
...
...
@@ -9,6 +9,7 @@ define(function (require) {
var
zrUtil
=
require
(
'
zrender/core/util
'
);
var
Model
=
require
(
'
./Model
'
);
var
OptionManager
=
require
(
'
./OptionManager
'
);
var
each
=
zrUtil
.
each
;
var
filter
=
zrUtil
.
filter
;
var
map
=
zrUtil
.
map
;
...
...
@@ -31,38 +32,51 @@ define(function (require) {
constructor
:
GlobalModel
,
init
:
function
(
option
,
parentModel
,
theme
)
{
init
:
function
(
option
,
parentModel
,
theme
,
optionPreprocessorFuncs
)
{
theme
=
theme
||
{};
this
.
option
=
{};
this
.
option
=
null
;
// Mark as not initialized.
/**
* @type {
Object.<string, Array.<module:echarts/model/Model>>
}
* @type {
module:echarts/model/Model
}
* @private
*/
this
.
_
componentsMap
=
{}
;
this
.
_
theme
=
new
Model
(
theme
)
;
/**
* Mapping between filtered series list and raw series list.
* key: filtered series indices, value: raw series indices.
* @type {Array.<nubmer>}
* @private
* @type {module:echarts/model/OptionManager}
*/
this
.
_seriesIndices
;
this
.
_optionManager
=
new
OptionManager
(
optionPreprocessorFuncs
);
},
/**
* @type {module:echarts/model/Model}
* @private
*/
this
.
_theme
=
new
Model
(
theme
);
setOption
:
function
(
option
)
{
var
optionManager
=
this
.
_optionManager
;
var
baseOption
=
optionManager
.
setOption
(
option
);
if
(
!
this
.
option
)
{
initBase
.
call
(
this
,
baseOption
);
}
else
{
this
.
restoreData
();
this
.
mergeOption
(
baseOption
);
}
this
.
updateTimelineOption
();
},
mergeTheme
(
option
,
theme
);
resetOption
:
function
()
{
initBase
.
call
(
this
,
this
.
_optionManager
.
resetOption
());
// TODO Needs clone when merging to the unexisted property
zrUtil
.
merge
(
option
,
globalDefault
,
false
);
this
.
updateTimelineOption
();
},
this
.
mergeOption
(
option
);
updateTimelineOption
:
function
()
{
var
partialOption
=
this
.
_optionManager
.
getTimelineOption
(
this
);
if
(
partialOption
)
{
this
.
restoreData
();
this
.
mergeOption
(
partialOption
);
}
},
/**
...
...
@@ -549,7 +563,6 @@ define(function (require) {
});
/**
* @inner
*/
...
...
@@ -569,6 +582,33 @@ define(function (require) {
}
}
function
initBase
(
baseOption
)
{
baseOption
=
baseOption
;
this
.
option
=
{};
/**
* @type {Object.<string, Array.<module:echarts/model/Model>>}
* @private
*/
this
.
_componentsMap
=
{};
/**
* Mapping between filtered series list and raw series list.
* key: filtered series indices, value: raw series indices.
* @type {Array.<nubmer>}
* @private
*/
this
.
_seriesIndices
=
null
;
mergeTheme
(
baseOption
,
this
.
_theme
.
option
);
// TODO Needs clone when merging to the unexisted property
zrUtil
.
merge
(
baseOption
,
globalDefault
,
false
);
this
.
mergeOption
(
baseOption
);
}
/**
* @inner
* @param {Array.<string>|string} types model types
...
...
src/model/OptionManager.js
浏览文件 @
927d6315
...
...
@@ -46,9 +46,6 @@ define(function (require) {
* {title: {...}, series: {data: [...]}},
* ...
* ],
* defaults: {
* {series: {x: 20}, dataRange: {show: false}}
* },
* media: [
* {
* query: {maxWidth: 320},
...
...
@@ -65,14 +62,40 @@ define(function (require) {
* };
*
* @alias module:echarts/model/OptionManager
*
* @param {Array.<Function>} optionPreprocessorFuncs
*/
function
OptionManager
()
{
function
OptionManager
(
optionPreprocessorFuncs
)
{
/**
* @private
* @type {Array.<number>}
*/
this
.
_timelineOptions
=
[];
this
.
_timelineOptions
;
/**
* @private
* @type {Array.<Object>}
*/
this
.
_mediaList
;
/**
* @private
* @type {Object}
*/
this
.
_mediaDefault
;
/**
* @private
* @type {Object}
*/
this
.
_rawOptionBackup
;
/**
* @private
* @type {Array.<Function>}
*/
this
.
_optionPreprocessorFuncs
=
optionPreprocessorFuncs
;
}
OptionManager
.
prototype
=
{
...
...
@@ -82,25 +105,30 @@ define(function (require) {
/**
* @public
* @param {Object} rawOption Raw option.
* @param {Array.<Function>} optionPreprocessorFuncs
* @param {module:echarts/model/Global} ecModel
* @return {Object} Init option
*/
updateRawOption
:
function
(
rawOption
,
optionPreprocessorFuncs
)
{
setOption
:
function
(
rawOption
)
{
rawOption
=
zrUtil
.
clone
(
rawOption
,
true
);
this
.
_rawOptionBackup
=
shadowClone
(
rawOption
);
// FIXME
// 如果 timeline options 或者 media 中设置了某个属性,而base中没有设置,则进行警告。
return
settleRawOption
.
call
(
this
,
rawOption
,
optionPreprocessorFuncs
);
return
settleRawOption
.
call
(
this
,
rawOption
,
this
.
_
optionPreprocessorFuncs
);
},
getPartialOption
:
function
(
ecModel
)
{
/**
* @param {module:echarts/model/Global} ecModel
* @return {Object}
*/
getTimelineOption
:
function
(
ecModel
)
{
var
option
;
var
timelineOptions
=
this
.
_timelineOptions
;
if
(
timelineOptions
.
length
)
{
// get
Partial
Option can only be called after ecModel inited,
// get
Timeline
Option can only be called after ecModel inited,
// so we can get currentIndex from timelineModel.
var
timelineModel
=
ecModel
.
getComponent
(
'
timeline
'
);
if
(
timelineModel
)
{
...
...
@@ -111,15 +139,22 @@ define(function (require) {
}
}
// FIXME
// and then merge media query option?
return
option
;
},
/**
* @param {module:echarts/model/Global} ecModel
* @return {Object}
*/
resetOption
:
function
(
optionPreprocessorFuncs
)
{
var
rawOption
=
shadowClone
(
this
.
_rawOptionBackup
);
return
settleRawOption
.
call
(
this
,
rawOption
,
this
.
_optionPreprocessorFuncs
);
}
};
function
settleRawOption
(
rawOption
,
optionPreprocessorFuncs
)
{
var
timelineOptions
=
[];
var
mediaList
=
[];
var
timelineOpt
=
rawOption
.
timeline
;
var
baseOption
;
...
...
@@ -129,19 +164,19 @@ define(function (require) {
timelineOptions
=
(
rawOption
.
options
||
[]).
slice
();
}
// For media query
else
if
(
rawOption
.
media
)
{
if
(
rawOption
.
media
)
{
baseOption
=
rawOption
.
base
||
{};
var
media
=
rawOption
.
media
;
each
(
media
,
function
(
singleMedia
)
{
singleMedia
&&
singleMedia
.
option
&&
timelineOptions
.
push
(
singleMedia
.
option
);
if
(
singleMedia
&&
singleMedia
.
option
)
{
mediaList
.
push
(
singleMedia
);
}
// else if (singleMedia && !singleMedia
});
}
// For normal option
else
{
if
(
!
baseOption
)
{
baseOption
=
rawOption
;
timelineOptions
.
push
(
rawOption
);
}
// Set timelineOpt to baseOption for convenience.
...
...
@@ -168,5 +203,20 @@ define(function (require) {
return
baseOption
;
}
function
applyMedia
(
ecModel
,
api
)
{
var
result
;
each
(
this
.
_mediaList
,
function
(
singleMedia
)
{
});
return
result
;
}
function
shadowClone
(
rawOption
)
{
// FIXME
return
zrUtil
.
clone
(
rawOption
,
true
);
}
return
OptionManager
;
});
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录