Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
x649585723
incubator-echarts
提交
52c0f4d6
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,发现更多精彩内容 >>
提交
52c0f4d6
编写于
6月 24, 2020
作者:
P
pissang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refact(sankey): use blur state.
上级
2e2a76e8
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
57 addition
and
97 deletion
+57
-97
src/chart/graph/GraphView.ts
src/chart/graph/GraphView.ts
+18
-12
src/chart/sankey/SankeyView.ts
src/chart/sankey/SankeyView.ts
+39
-85
未找到文件。
src/chart/graph/GraphView.ts
浏览文件 @
52c0f4d6
...
...
@@ -53,21 +53,26 @@ function isViewCoordSys(coordSys: CoordinateSystem): coordSys is View {
function
fadeInItem
(
nodeOrEdge
:
GraphNode
|
GraphEdge
)
{
const
el
=
nodeOrEdge
.
getGraphicEl
()
as
Symbol
|
Line
;
if
((
el
as
Symbol
).
getSymbolPath
)
{
(
el
as
Symbol
).
getSymbolPath
().
removeState
(
'
blur
'
);
}
else
{
(
el
as
Line
).
getLinePath
().
removeState
(
'
blur
'
);
if
(
el
)
{
if
((
el
as
Symbol
).
getSymbolPath
)
{
(
el
as
Symbol
).
getSymbolPath
().
removeState
(
'
blur
'
);
}
else
{
(
el
as
Line
).
getLinePath
().
removeState
(
'
blur
'
);
}
}
}
function
fadeOutItem
(
nodeOrEdge
:
GraphNode
|
GraphEdge
)
{
const
el
=
nodeOrEdge
.
getGraphicEl
()
as
Symbol
|
Line
;
if
((
el
as
Symbol
).
getSymbolPath
)
{
(
el
as
Symbol
).
getSymbolPath
().
useState
(
'
blur
'
);
}
else
{
(
el
as
Line
).
getLinePath
().
useState
(
'
blur
'
);
if
(
el
)
{
if
((
el
as
Symbol
).
getSymbolPath
)
{
(
el
as
Symbol
).
getSymbolPath
().
useState
(
'
blur
'
);
}
else
{
(
el
as
Line
).
getLinePath
().
useState
(
'
blur
'
);
}
}
}
...
...
@@ -183,7 +188,8 @@ class GraphView extends ChartView {
const
symbolPath
=
el
.
getSymbolPath
();
const
blurState
=
symbolPath
.
ensureState
(
'
blur
'
);
blurState
.
style
=
{
opacity
:
symbolPath
.
style
.
opacity
*
0.1
// TODO Based on the original opacity.
opacity
:
0.1
};
el
.
on
(
'
mouseover
'
,
(
el
as
any
)[
FOCUS_ADJACENCY
]
=
function
()
{
...
...
@@ -211,7 +217,7 @@ class GraphView extends ChartView {
const
linePath
=
el
.
getLinePath
();
const
blurState
=
linePath
.
ensureState
(
'
blur
'
);
blurState
.
style
=
{
opacity
:
linePath
.
style
.
opacity
*
0.1
opacity
:
0.1
};
el
.
on
(
'
mouseover
'
,
(
el
as
any
)[
FOCUS_ADJACENCY
]
=
function
()
{
...
...
src/chart/sankey/SankeyView.ts
浏览文件 @
52c0f4d6
...
...
@@ -26,15 +26,10 @@ import ChartView from '../../view/Chart';
import
GlobalModel
from
'
../../model/Global
'
;
import
ExtensionAPI
from
'
../../ExtensionAPI
'
;
import
{
GraphNode
,
GraphEdge
}
from
'
../../data/Graph
'
;
import
{
Graph
NodeItemOption
,
Graph
EdgeItemOption
}
from
'
../graph/GraphSeries
'
;
import
{
GraphEdgeItemOption
}
from
'
../graph/GraphSeries
'
;
import
List
from
'
../../data/List
'
;
import
{
RectLike
}
from
'
zrender/src/core/BoundingRect
'
;
const
nodeOpacityPath
=
[
'
itemStyle
'
,
'
opacity
'
]
as
const
;
const
hoverNodeOpacityPath
=
[
'
emphasis
'
,
'
itemStyle
'
,
'
opacity
'
]
as
const
;
const
lineOpacityPath
=
[
'
lineStyle
'
,
'
opacity
'
]
as
const
;
const
hoverLineOpacityPath
=
[
'
emphasis
'
,
'
lineStyle
'
,
'
opacity
'
]
as
const
;
interface
FocusNodeAdjacencyPayload
extends
Payload
{
dataIndex
?:
number
edgeDataIndex
?:
number
...
...
@@ -48,54 +43,19 @@ interface SankeyEl extends graphic.Path {
unfocusNodeAdjHandler
():
void
}
function
getItemOpacity
(
item
:
GraphNode
|
GraphEdge
,
opacityPath
:
readonly
string
[]
):
number
{
return
item
.
getVisual
(
'
opacity
'
)
// TODO: TYPE
||
item
.
getModel
<
GraphNodeItemOption
>
().
get
(
opacityPath
as
typeof
nodeOpacityPath
);
}
function
fadeOutItem
(
item
:
GraphNode
|
GraphEdge
,
opacityPath
:
readonly
string
[],
opacityRatio
?:
number
)
{
const
el
=
item
.
getGraphicEl
()
as
SankeyEl
;
let
opacity
=
getItemOpacity
(
item
,
opacityPath
);
if
(
opacityRatio
!=
null
)
{
opacity
==
null
&&
(
opacity
=
1
);
opacity
*=
opacityRatio
;
function
fadeInItem
(
nodeOrEdge
:
GraphNode
|
GraphEdge
)
{
const
el
=
nodeOrEdge
.
getGraphicEl
();
if
(
el
)
{
el
.
removeState
(
'
blur
'
);
}
el
.
downplay
&&
el
.
downplay
();
el
.
traverse
(
function
(
child
)
{
if
(
child
.
type
!==
'
group
'
)
{
child
.
setStyle
(
'
opacity
'
,
opacity
);
}
});
}
function
fadeInItem
(
item
:
GraphNode
|
GraphEdge
,
opacityPath
:
readonly
string
[]
)
{
const
opacity
=
getItemOpacity
(
item
,
opacityPath
);
const
el
=
item
.
getGraphicEl
()
as
SankeyEl
;
// Support emphasis here.
el
.
highlight
&&
el
.
highlight
();
el
.
traverse
(
function
(
child
)
{
if
(
child
.
type
!==
'
group
'
)
{
child
.
setStyle
(
'
opacity
'
,
opacity
);
}
});
function
fadeOutItem
(
nodeOrEdge
:
GraphNode
|
GraphEdge
)
{
const
el
=
nodeOrEdge
.
getGraphicEl
();
if
(
el
)
{
el
.
useState
(
'
blur
'
);
}
}
class
SankeyPathShape
{
x1
=
0
;
y1
=
0
;
...
...
@@ -175,8 +135,6 @@ class SankeyView extends ChartView {
private
_data
:
List
;
private
_unfocusDelayTimer
:
number
;
render
(
seriesModel
:
SankeySeriesModel
,
ecModel
:
GlobalModel
,
api
:
ExtensionAPI
)
{
const
sankeyView
=
this
;
const
graph
=
seriesModel
.
getGraph
();
...
...
@@ -357,9 +315,13 @@ class SankeyView extends ChartView {
el
.
unfocusNodeAdjHandler
&&
el
.
off
(
'
mouseout
'
,
el
.
unfocusNodeAdjHandler
);
if
(
itemModel
.
get
(
'
focusNodeAdjacency
'
))
{
const
blurState
=
el
.
ensureState
(
'
blur
'
);
blurState
.
style
=
{
opacity
:
0.1
};
el
.
on
(
'
mouseover
'
,
el
.
focusNodeAdjHandler
=
function
()
{
if
(
!
sankeyView
.
_focusAdjacencyDisabled
)
{
sankeyView
.
_clearTimer
();
api
.
dispatchAction
({
type
:
'
focusNodeAdjacency
'
,
seriesId
:
seriesModel
.
id
,
...
...
@@ -383,9 +345,13 @@ class SankeyView extends ChartView {
el
.
unfocusNodeAdjHandler
&&
el
.
off
(
'
mouseout
'
,
el
.
unfocusNodeAdjHandler
);
if
(
edgeModel
.
get
(
'
focusNodeAdjacency
'
))
{
const
blurState
=
el
.
ensureState
(
'
blur
'
);
blurState
.
style
=
{
opacity
:
0.1
};
el
.
on
(
'
mouseover
'
,
el
.
focusNodeAdjHandler
=
function
()
{
if
(
!
sankeyView
.
_focusAdjacencyDisabled
)
{
sankeyView
.
_clearTimer
();
api
.
dispatchAction
({
type
:
'
focusNodeAdjacency
'
,
seriesId
:
seriesModel
.
id
,
...
...
@@ -412,26 +378,14 @@ class SankeyView extends ChartView {
}
dispose
()
{
this
.
_clearTimer
();
}
_dispatchUnfocus
(
api
:
ExtensionAPI
)
{
const
self
=
this
;
this
.
_clearTimer
();
this
.
_unfocusDelayTimer
=
setTimeout
(
function
()
{
self
.
_unfocusDelayTimer
=
null
;
api
.
dispatchAction
({
type
:
'
unfocusNodeAdjacency
'
,
seriesId
:
self
.
_model
.
id
});
},
500
)
as
any
;
}
_clearTimer
()
{
if
(
this
.
_unfocusDelayTimer
)
{
clearTimeout
(
this
.
_unfocusDelayTimer
);
this
.
_unfocusDelayTimer
=
null
;
}
api
.
dispatchAction
({
type
:
'
unfocusNodeAdjacency
'
,
seriesId
:
self
.
_model
.
id
});
}
focusNodeAdjacency
(
...
...
@@ -452,23 +406,23 @@ class SankeyView extends ChartView {
const
edge
=
graph
.
getEdgeByIndex
(
edgeDataIndex
);
graph
.
eachNode
(
function
(
node
)
{
fadeOutItem
(
node
,
nodeOpacityPath
,
0.1
);
fadeOutItem
(
node
);
});
graph
.
eachEdge
(
function
(
edge
)
{
fadeOutItem
(
edge
,
lineOpacityPath
,
0.1
);
fadeOutItem
(
edge
);
});
if
(
node
)
{
const
itemModel
=
data
.
getItemModel
<
SankeyNodeItemOption
>
(
dataIndex
);
fadeInItem
(
node
,
hoverNodeOpacityPath
);
fadeInItem
(
node
);
const
focusNodeAdj
=
itemModel
.
get
(
'
focusNodeAdjacency
'
);
if
(
focusNodeAdj
===
'
outEdges
'
)
{
zrUtil
.
each
(
node
.
outEdges
,
function
(
edge
)
{
if
(
edge
.
dataIndex
<
0
)
{
return
;
}
fadeInItem
(
edge
,
hoverLineOpacityPath
);
fadeInItem
(
edge
.
node2
,
hoverNodeOpacityPath
);
fadeInItem
(
edge
);
fadeInItem
(
edge
.
node2
);
});
}
else
if
(
focusNodeAdj
===
'
inEdges
'
)
{
...
...
@@ -476,8 +430,8 @@ class SankeyView extends ChartView {
if
(
edge
.
dataIndex
<
0
)
{
return
;
}
fadeInItem
(
edge
,
hoverLineOpacityPath
);
fadeInItem
(
edge
.
node1
,
hoverNodeOpacityPath
);
fadeInItem
(
edge
);
fadeInItem
(
edge
.
node1
);
});
}
else
if
(
focusNodeAdj
===
'
allEdges
'
)
{
...
...
@@ -485,16 +439,16 @@ class SankeyView extends ChartView {
if
(
edge
.
dataIndex
<
0
)
{
return
;
}
fadeInItem
(
edge
,
hoverLineOpacityPath
);
(
edge
.
node1
!==
node
)
&&
fadeInItem
(
edge
.
node1
,
hoverNodeOpacityPath
);
(
edge
.
node2
!==
node
)
&&
fadeInItem
(
edge
.
node2
,
hoverNodeOpacityPath
);
fadeInItem
(
edge
);
(
edge
.
node1
!==
node
)
&&
fadeInItem
(
edge
.
node1
);
(
edge
.
node2
!==
node
)
&&
fadeInItem
(
edge
.
node2
);
});
}
}
if
(
edge
)
{
fadeInItem
(
edge
,
hoverLineOpacityPath
);
fadeInItem
(
edge
.
node1
,
hoverNodeOpacityPath
);
fadeInItem
(
edge
.
node2
,
hoverNodeOpacityPath
);
fadeInItem
(
edge
);
fadeInItem
(
edge
.
node1
);
fadeInItem
(
edge
.
node2
);
}
}
...
...
@@ -504,10 +458,10 @@ class SankeyView extends ChartView {
const
graph
=
seriesModel
.
getGraph
();
graph
.
eachNode
(
function
(
node
)
{
fade
OutItem
(
node
,
nodeOpacityPath
);
fade
InItem
(
node
);
});
graph
.
eachEdge
(
function
(
edge
)
{
fade
OutItem
(
edge
,
lineOpacityPath
);
fade
InItem
(
edge
);
});
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录