Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
半栈学徒
incubator-echarts
提交
ea27d0a8
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,发现更多精彩内容 >>
提交
ea27d0a8
编写于
12月 26, 2015
作者:
P
pah100
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix preprocessor.
上级
dd720677
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
156 addition
and
39 deletion
+156
-39
src/component/timeline/timelineAction.js
src/component/timeline/timelineAction.js
+1
-1
src/echarts.js
src/echarts.js
+7
-2
src/model/Global.js
src/model/Global.js
+36
-21
src/model/OptionManager.js
src/model/OptionManager.js
+112
-15
未找到文件。
src/component/timeline/timelineAction.js
浏览文件 @
ea27d0a8
...
...
@@ -20,7 +20,7 @@ define(function(require) {
}
}
ecModel
.
updateTimelineOption
(
);
ecModel
.
resetOption
(
'
timeline
'
);
}
);
...
...
src/echarts.js
浏览文件 @
ea27d0a8
...
...
@@ -16,6 +16,7 @@ define(function (require) {
var
GlobalModel
=
require
(
'
./model/Global
'
);
var
ExtensionAPI
=
require
(
'
./ExtensionAPI
'
);
var
CoordinateSystemManager
=
require
(
'
./CoordinateSystem
'
);
var
OptionManager
=
require
(
'
./model/OptionManager
'
);
var
ComponentModel
=
require
(
'
./model/Component
'
);
var
SeriesModel
=
require
(
'
./model/Series
'
);
...
...
@@ -159,7 +160,9 @@ define(function (require) {
echartsProto
.
setOption
=
function
(
option
,
notMerge
,
notRefreshImmediately
)
{
if
(
!
this
.
_model
||
notMerge
)
{
this
.
_model
=
new
GlobalModel
(
null
,
null
,
this
.
_theme
);
this
.
_model
=
new
GlobalModel
(
null
,
null
,
this
.
_theme
,
new
OptionManager
(
this
.
_api
)
);
}
this
.
_model
.
setOption
(
option
,
optionPreprocessorFuncs
);
...
...
@@ -472,7 +475,9 @@ define(function (require) {
*/
echartsProto
.
resize
=
function
()
{
this
.
_zr
.
resize
();
updateMethods
.
update
.
call
(
this
);
var
optionChanged
=
this
.
_model
&&
this
.
_model
.
resetOption
(
'
media
'
);
updateMethods
[
optionChanged
?
'
prepareAndUpdate
'
:
'
update
'
].
call
(
this
);
// Resize loading effect
this
.
_loadingFX
&&
this
.
_loadingFX
.
resize
();
...
...
src/model/Global.js
浏览文件 @
ea27d0a8
...
...
@@ -9,7 +9,6 @@ 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
;
...
...
@@ -32,7 +31,7 @@ define(function (require) {
constructor
:
GlobalModel
,
init
:
function
(
option
,
parentModel
,
theme
)
{
init
:
function
(
option
,
parentModel
,
theme
,
optionManager
)
{
theme
=
theme
||
{};
this
.
option
=
null
;
// Mark as not initialized.
...
...
@@ -46,37 +45,53 @@ define(function (require) {
/**
* @type {module:echarts/model/OptionManager}
*/
this
.
_optionManager
=
new
OptionManager
()
;
this
.
_optionManager
=
optionManager
;
},
setOption
:
function
(
option
,
optionPreprocessorFuncs
)
{
this
.
_optionManager
.
setOption
(
option
,
optionPreprocessorFuncs
);
this
.
resetOption
();
},
/**
* @param {string} type null/undefined: reset all.
* 'timeline': only reset timeline option
* 'media': only reset media query option
* @return {boolean} Whether option changed.
*/
resetOption
:
function
(
type
)
{
var
optionChanged
=
false
;
var
optionManager
=
this
.
_optionManager
;
var
baseOption
=
optionManager
.
setOption
(
option
);
if
(
!
type
)
{
var
baseOption
=
optionManager
.
mountOption
();
if
(
!
this
.
option
)
{
initBase
.
call
(
this
,
baseOption
);
if
(
!
this
.
option
)
{
initBase
.
call
(
this
,
baseOption
);
}
else
{
this
.
restoreData
();
this
.
mergeOption
(
baseOption
);
}
optionChanged
=
true
;
}
else
{
if
(
type
===
'
timeline
'
||
type
===
'
media
'
)
{
this
.
restoreData
();
this
.
mergeOption
(
baseOption
);
}
this
.
updateTimelineOption
();
},
resetOption
:
function
()
{
initBase
.
call
(
this
,
this
.
_optionManager
.
resetOption
());
this
.
updateTimelineOption
();
},
if
(
!
type
||
type
===
'
timeline
'
)
{
var
partialOption
=
optionManager
.
getTimelineOption
(
this
);
partialOption
&&
(
this
.
mergeOption
(
partialOption
),
optionChanged
=
true
);
}
updateTimelineOption
:
function
()
{
var
partialOption
=
this
.
_optionManager
.
getTimelineOption
(
this
);
if
(
partialOption
)
{
this
.
restoreData
();
this
.
mergeOption
(
partialOption
);
if
(
!
type
||
type
===
'
media
'
)
{
var
partialOption
=
optionManager
.
getMediaOption
(
this
,
this
.
_api
);
partialOption
&&
(
this
.
mergeOption
(
partialOption
),
optionChanged
=
true
);
}
return
optionChanged
;
},
/**
...
...
src/model/OptionManager.js
浏览文件 @
ea27d0a8
...
...
@@ -9,6 +9,9 @@ define(function (require) {
var
zrUtil
=
require
(
'
zrender/core/util
'
);
var
each
=
zrUtil
.
each
;
var
clone
=
zrUtil
.
clone
;
var
map
=
zrUtil
.
map
;
var
QUERY_REG
=
/^
(
min|max
)?(
.+
)
$/
;
/**
* TERM EXPLANATIONS:
...
...
@@ -63,8 +66,15 @@ define(function (require) {
* };
*
* @alias module:echarts/model/OptionManager
* @param {module:echarts/ExtensionAPI} api
*/
function
OptionManager
()
{
function
OptionManager
(
api
)
{
/**
* @private
* @type {module:echarts/ExtensionAPI}
*/
this
.
_api
=
api
;
/**
* @private
...
...
@@ -84,6 +94,13 @@ define(function (require) {
*/
this
.
_mediaDefault
;
/**
* -1, means default.
* null means no media.
* @private
*/
this
.
_currentMediaIndex
=
null
;
/**
* @private
* @type {Object}
...
...
@@ -120,8 +137,23 @@ define(function (require) {
this
.
_optionBackup
=
parseRawOption
.
call
(
this
,
rawOption
,
optionPreprocessorFuncs
);
},
return
this
.
resetOption
();
/**
* @return {Object}
*/
mountOption
:
function
()
{
var
optionBackup
=
this
.
_optionBackup
;
// FIXME
// 如果没有reset功能则不clone。
this
.
_timelineOptions
=
map
(
optionBackup
.
timelineOptions
,
clone
);
this
.
_mediaList
=
map
(
optionBackup
.
mediaList
,
clone
);
this
.
_mediaDefault
=
clone
(
optionBackup
.
mediaDefault
);
this
.
_currentMediaIndex
=
null
;
return
clone
(
optionBackup
.
baseOption
);
},
/**
...
...
@@ -148,23 +180,44 @@ define(function (require) {
},
/**
* @param {module:echarts/model/Global} ecModel
* @return {Object}
*/
resetOption
:
function
()
{
var
optionBackup
=
this
.
_optionBackup
;
getMediaOption
:
function
(
ecModel
)
{
var
ecWidth
=
this
.
_api
.
getWidth
();
var
ecHeight
=
this
.
_api
.
getHeight
();
var
mediaList
=
this
.
_mediaList
;
var
index
;
// FIXME
// 如果没有reset功能则不clone。
for
(
var
i
=
0
,
len
=
mediaList
.
length
;
i
<
len
;
i
++
)
{
var
query
=
mediaList
[
i
].
query
;
if
(
applyMediaQuery
(
query
,
ecWidth
,
ecHeight
))
{
index
=
i
;
break
;
}
}
this
.
_timelineOptions
=
zrUtil
.
map
(
optionBackup
.
timelineOptions
,
clone
);
if
(
this
.
_mediaDefault
)
{
index
=
-
1
;
}
return
clone
(
optionBackup
.
baseOption
);
if
(
index
!=
null
&&
index
!==
this
.
_currentMediaIndex
)
{
this
.
_currentMediaIndex
=
index
;
return
clone
(
index
===
-
1
?
this
.
_mediaDefault
.
option
:
mediaList
[
index
].
option
,
true
);
}
// Otherwise return nothing.
}
};
function
parseRawOption
(
rawOption
,
optionPreprocessorFuncs
)
{
var
timelineOptions
=
[];
var
mediaList
=
[];
var
mediaDefault
;
var
timelineOpt
=
rawOption
.
timeline
;
var
baseOption
;
...
...
@@ -179,9 +232,14 @@ define(function (require) {
var
media
=
rawOption
.
media
;
each
(
media
,
function
(
singleMedia
)
{
if
(
singleMedia
&&
singleMedia
.
option
)
{
mediaList
.
push
(
singleMedia
);
if
(
singleMedia
.
query
)
{
mediaList
.
push
(
singleMedia
);
}
else
if
(
!
mediaDefault
)
{
// Use the first media default.
mediaDefault
=
singleMedia
;
}
}
// else if (singleMedia && !singleMedia
});
}
// For normal option
...
...
@@ -199,17 +257,56 @@ define(function (require) {
});
});
return
{
baseOption
:
baseOption
,
timelineOptions
:
timelineOptions
};
return
{
baseOption
:
baseOption
,
timelineOptions
:
timelineOptions
,
mediaDefault
:
mediaDefault
,
mediaList
:
mediaList
};
}
function
applyMedia
(
ecModel
,
api
)
{
var
result
;
/**
* @see <http://www.w3.org/TR/css3-mediaqueries/#media1>
* Support: width, height, aspectRatio
* Can use max or min as prefix.
*/
function
applyMediaQuery
(
query
,
ecWidth
,
ecHeight
)
{
var
realMap
=
{
width
:
ecWidth
,
height
:
ecHeight
,
aspectratio
:
ecWidth
/
ecHeight
// lowser case for convenientce.
};
var
applicatable
=
true
;
zrUtil
.
each
(
query
,
function
(
value
,
attr
)
{
var
matched
=
attr
.
match
(
QUERY_REG
);
each
(
this
.
_mediaList
,
function
(
singleMedia
)
{
if
(
!
matched
||
!
matched
[
1
]
||
!
matched
[
2
])
{
return
;
}
var
operator
=
matched
[
1
];
var
realAttr
=
matched
[
2
].
toLowerCase
();
if
(
!
compare
(
realMap
[
realAttr
],
value
,
operator
))
{
applicatable
=
false
;
}
});
return
result
;
return
applicatable
;
}
function
compare
(
real
,
expect
,
operator
)
{
if
(
operator
===
'
min
'
)
{
return
real
<=
expect
;
}
else
if
(
operator
===
'
max
'
)
{
return
real
>=
expect
;
}
else
{
// Equals
return
real
===
expect
;
}
}
return
OptionManager
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录