Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
x649585723
incubator-echarts
提交
a142d777
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,发现更多精彩内容 >>
提交
a142d777
编写于
1月 11, 2018
作者:
S
sushuang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add isInstance to avoid "instanceof" fail when cross scope.
上级
161903e0
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
36 addition
and
9 deletion
+36
-9
src/data/Graph.js
src/data/Graph.js
+9
-5
src/data/List.js
src/data/List.js
+1
-1
src/data/Source.js
src/data/Source.js
+3
-0
src/data/helper/completeDimensions.js
src/data/helper/completeDimensions.js
+1
-1
src/data/helper/dataProvider.js
src/data/helper/dataProvider.js
+1
-1
src/helper.js
src/helper.js
+1
-1
src/util/clazz.js
src/util/clazz.js
+20
-0
未找到文件。
src/data/Graph.js
浏览文件 @
a142d777
...
...
@@ -7,6 +7,7 @@
import
{
__DEV__
}
from
'
../config
'
;
import
*
as
zrUtil
from
'
zrender/src/core/util
'
;
import
{
enableClassCheck
}
from
'
../util/clazz
'
;
// id may be function name of Object, add a prefix to avoid this problem.
function
generateNodeKey
(
id
)
{
...
...
@@ -138,10 +139,10 @@ graphProto.addEdge = function (n1, n2, dataIndex) {
n2
=
this
.
nodes
[
n2
];
}
if
(
!
(
n1
instanceof
Node
))
{
if
(
!
Node
.
isInstance
(
n1
))
{
n1
=
nodesMap
[
generateNodeKey
(
n1
)];
}
if
(
!
(
n2
instanceof
Node
))
{
if
(
!
Node
.
isInstance
(
n2
))
{
n2
=
nodesMap
[
generateNodeKey
(
n2
)];
}
if
(
!
n1
||
!
n2
)
{
...
...
@@ -188,10 +189,10 @@ graphProto.getEdgeByIndex = function (dataIndex) {
* @return {module:echarts/data/Graph.Edge}
*/
graphProto
.
getEdge
=
function
(
n1
,
n2
)
{
if
(
n1
instanceof
Node
)
{
if
(
Node
.
isInstance
(
n1
)
)
{
n1
=
n1
.
id
;
}
if
(
n2
instanceof
Node
)
{
if
(
Node
.
isInstance
(
n2
)
)
{
n2
=
n2
.
id
;
}
...
...
@@ -248,7 +249,7 @@ graphProto.eachEdge = function (cb, context) {
graphProto
.
breadthFirstTraverse
=
function
(
cb
,
startNode
,
direction
,
context
)
{
if
(
!
(
startNode
instanceof
Node
))
{
if
(
!
Node
.
isInstance
(
start
Node
))
{
startNode
=
this
.
_nodesMap
[
generateNodeKey
(
startNode
)];
}
if
(
!
startNode
)
{
...
...
@@ -516,4 +517,7 @@ zrUtil.mixin(Edge, createGraphDataProxyMixin('hostGraph', 'edgeData'));
Graph
.
Node
=
Node
;
Graph
.
Edge
=
Edge
;
enableClassCheck
(
Node
);
enableClassCheck
(
Edge
);
export
default
Graph
;
\ No newline at end of file
src/data/List.js
浏览文件 @
a142d777
...
...
@@ -327,7 +327,7 @@ listProto.mapDimension = function (coordDim, idx) {
*/
listProto
.
initData
=
function
(
data
,
nameList
,
dimValueGetter
)
{
var
notProvider
=
data
instanceof
Source
||
zrUtil
.
isArrayLike
(
data
);
var
notProvider
=
Source
.
isInstance
(
data
)
||
zrUtil
.
isArrayLike
(
data
);
if
(
notProvider
)
{
data
=
new
DefaultDataProvider
(
data
,
this
.
dimensions
.
length
);
}
...
...
src/data/Source.js
浏览文件 @
a142d777
import
{
createHashMap
,
isTypedArray
}
from
'
zrender/src/core/util
'
;
import
{
enableClassCheck
}
from
'
../util/clazz
'
;
import
{
SOURCE_FORMAT_ORIGINAL
,
SERIES_LAYOUT_BY_COLUMN
,
...
...
@@ -124,4 +125,6 @@ Source.seriesDataToSource = function (data) {
});
};
enableClassCheck
(
Source
);
export
default
Source
;
\ No newline at end of file
src/data/helper/completeDimensions.js
浏览文件 @
a142d777
...
...
@@ -52,7 +52,7 @@ import {OTHER_DIMENSIONS} from './dimensionHelper';
*/
function
completeDimensions
(
sysDims
,
source
,
opt
)
{
// ??? remove the compatible?
if
(
!
(
source
instanceof
S
ource
))
{
if
(
!
Source
.
isInstance
(
s
ource
))
{
source
=
Source
.
seriesDataToSource
(
source
);
}
...
...
src/data/helper/dataProvider.js
浏览文件 @
a142d777
...
...
@@ -19,7 +19,7 @@ import {
* If typed array used, chunk size must be fixed.
*/
export
function
DefaultDataProvider
(
source
,
dimSize
)
{
if
(
!
(
source
instanceof
S
ource
))
{
if
(
!
Source
.
isInstance
(
s
ource
))
{
source
=
Source
.
seriesDataToSource
(
source
);
}
this
.
_source
=
source
;
...
...
src/helper.js
浏览文件 @
a142d777
...
...
@@ -48,7 +48,7 @@ export {createSymbol} from './util/symbol';
*/
export
function
createScale
(
dataExtent
,
option
)
{
var
axisModel
=
option
;
if
(
!
(
option
instanceof
Model
))
{
if
(
!
Model
.
isInstance
(
option
))
{
axisModel
=
new
Model
(
option
);
zrUtil
.
mixin
(
axisModel
,
axisModelCommonMixin
);
}
...
...
src/util/clazz.js
浏览文件 @
a142d777
...
...
@@ -69,6 +69,26 @@ export function enableClassExtend(RootClass, mandatoryMethods) {
};
}
var
classBase
=
0
;
/**
* Can not use instanceof, consider different scope by
* cross domain or es module import in ec extensions.
* Mount a method "isInstance()" to Clz.
*/
export
function
enableClassCheck
(
Clz
)
{
var
classAttr
=
[
'
__
\
0is_clz
'
,
classBase
++
,
Math
.
random
().
toFixed
(
3
)].
join
(
'
_
'
);
Clz
.
prototype
[
classAttr
]
=
true
;
if
(
__DEV__
)
{
zrUtil
.
assert
(
!
Clz
.
isInstance
,
'
The method "is" can not be defined.
'
);
}
Clz
.
isInstance
=
function
(
obj
)
{
return
!!
(
obj
&&
obj
[
classAttr
]);
};
}
// superCall should have class info, which can not be fetch from 'this'.
// Consider this case:
// class A has method f,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录