Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
x649585723
incubator-echarts
提交
2e2a76e8
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,发现更多精彩内容 >>
提交
2e2a76e8
编写于
6月 24, 2020
作者:
P
pissang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refact(graph): use blur state instead of change opacity by manual
上级
abdb8319
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
52 addition
and
83 deletion
+52
-83
src/chart/graph/GraphView.ts
src/chart/graph/GraphView.ts
+46
-81
src/chart/helper/Line.ts
src/chart/helper/Line.ts
+4
-0
src/chart/helper/Symbol.ts
src/chart/helper/Symbol.ts
+1
-1
src/component/helper/roamHelper.ts
src/component/helper/roamHelper.ts
+1
-1
未找到文件。
src/chart/graph/GraphView.ts
浏览文件 @
2e2a76e8
...
...
@@ -32,20 +32,16 @@ import ExtensionAPI from '../../ExtensionAPI';
import
GraphSeriesModel
,
{
GraphNodeItemOption
,
GraphEdgeItemOption
}
from
'
./GraphSeries
'
;
import
{
CoordinateSystem
}
from
'
../../coord/CoordinateSystem
'
;
import
View
from
'
../../coord/View
'
;
import
{
GraphNode
,
GraphEdge
}
from
'
../../data/Graph
'
;
import
Displayable
from
'
zrender/src/graphic/Displayable
'
;
import
Symbol
from
'
../helper/Symbol
'
;
import
Model
from
'
../../model/Model
'
;
import
{
Payload
}
from
'
../../util/types
'
;
import
{
LineLabel
}
from
'
../helper/Line
'
;
import
List
from
'
../../data/List
'
;
import
Line
from
'
../helper/Line
'
;
import
{
GraphNode
,
GraphEdge
}
from
'
../../data/Graph
'
;
const
FOCUS_ADJACENCY
=
'
__focusNodeAdjacency
'
;
const
UNFOCUS_ADJACENCY
=
'
__unfocusNodeAdjacency
'
;
const
nodeOpacityPath
=
[
'
itemStyle
'
,
'
opacity
'
]
as
const
;
const
lineOpacityPath
=
[
'
lineStyle
'
,
'
opacity
'
]
as
const
;
interface
FocusNodePayload
extends
Payload
{
dataIndex
:
number
edgeDataIndex
:
number
...
...
@@ -55,53 +51,24 @@ function isViewCoordSys(coordSys: CoordinateSystem): coordSys is View {
return
coordSys
.
type
===
'
view
'
;
}
function
getItemOpacity
(
item
:
GraphNode
|
GraphEdge
,
opacityPath
:
typeof
nodeOpacityPath
|
typeof
lineOpacityPath
):
number
{
const
opacity
=
item
.
getVisual
(
'
opacity
'
);
return
opacity
!=
null
?
opacity
:
item
.
getModel
<
any
>
().
get
(
opacityPath
);
}
function
fadeOutItem
(
item
:
GraphNode
|
GraphEdge
,
opacityPath
:
typeof
nodeOpacityPath
|
typeof
lineOpacityPath
,
opacityRatio
?:
number
)
{
const
el
=
item
.
getGraphicEl
()
as
Symbol
;
// TODO Symbol?
let
opacity
=
getItemOpacity
(
item
,
opacityPath
);
if
(
opacityRatio
!=
null
)
{
opacity
==
null
&&
(
opacity
=
1
);
opacity
*=
opacityRatio
;
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
'
);
}
el
.
downplay
&&
el
.
downplay
();
el
.
traverse
(
function
(
child
:
LineLabel
)
{
if
(
!
child
.
isGroup
)
{
let
opct
=
child
.
lineLabelOriginalOpacity
;
if
(
opct
==
null
||
opacityRatio
!=
null
)
{
opct
=
opacity
;
}
child
.
setStyle
(
'
opacity
'
,
opct
);
}
});
}
function
fadeInItem
(
item
:
GraphNode
|
GraphEdge
,
opacityPath
:
typeof
nodeOpacityPath
|
typeof
lineOpacityPath
)
{
const
opacity
=
getItemOpacity
(
item
,
opacityPath
);
const
el
=
item
.
getGraphicEl
()
as
Symbol
;
// Should go back to normal opacity first, consider hoverLayer,
// where current state is copied to elMirror, and support
// emphasis opacity here.
el
.
traverse
(
function
(
child
:
Displayable
)
{
!
child
.
isGroup
&&
child
.
setStyle
(
'
opacity
'
,
opacity
);
});
el
.
highlight
&&
el
.
highlight
();
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
'
);
}
}
class
GraphView
extends
ChartView
{
...
...
@@ -120,7 +87,6 @@ class GraphView extends ChartView {
private
_model
:
GraphSeriesModel
;
private
_layoutTimeout
:
number
;
private
_unfocusDelayTimer
:
number
;
private
_layouting
:
boolean
;
...
...
@@ -214,8 +180,13 @@ class GraphView extends ChartView {
(
el
as
any
)[
UNFOCUS_ADJACENCY
]
&&
el
.
off
(
'
mouseout
'
,
(
el
as
any
)[
UNFOCUS_ADJACENCY
]);
if
(
itemModel
.
get
(
'
focusNodeAdjacency
'
))
{
const
symbolPath
=
el
.
getSymbolPath
();
const
blurState
=
symbolPath
.
ensureState
(
'
blur
'
);
blurState
.
style
=
{
opacity
:
symbolPath
.
style
.
opacity
*
0.1
};
el
.
on
(
'
mouseover
'
,
(
el
as
any
)[
FOCUS_ADJACENCY
]
=
function
()
{
graphView
.
_clearTimer
();
api
.
dispatchAction
({
type
:
'
focusNodeAdjacency
'
,
seriesId
:
seriesModel
.
id
,
...
...
@@ -230,14 +201,20 @@ class GraphView extends ChartView {
});
data
.
graph
.
eachEdge
(
function
(
edge
)
{
const
el
=
edge
.
getGraphicEl
();
const
el
=
edge
.
getGraphicEl
()
as
Line
;
(
el
as
any
)[
FOCUS_ADJACENCY
]
&&
el
.
off
(
'
mouseover
'
,
(
el
as
any
)[
FOCUS_ADJACENCY
]);
(
el
as
any
)[
UNFOCUS_ADJACENCY
]
&&
el
.
off
(
'
mouseout
'
,
(
el
as
any
)[
UNFOCUS_ADJACENCY
]);
if
(
edge
.
getModel
<
GraphEdgeItemOption
>
().
get
(
'
focusNodeAdjacency
'
))
{
const
linePath
=
el
.
getLinePath
();
const
blurState
=
linePath
.
ensureState
(
'
blur
'
);
blurState
.
style
=
{
opacity
:
linePath
.
style
.
opacity
*
0.1
};
el
.
on
(
'
mouseover
'
,
(
el
as
any
)[
FOCUS_ADJACENCY
]
=
function
()
{
graphView
.
_clearTimer
();
api
.
dispatchAction
({
type
:
'
focusNodeAdjacency
'
,
seriesId
:
seriesModel
.
id
,
...
...
@@ -293,27 +270,15 @@ class GraphView extends ChartView {
dispose
()
{
this
.
_controller
&&
this
.
_controller
.
dispose
();
this
.
_controllerHost
=
null
;
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
;
}
api
.
dispatchAction
({
type
:
'
unfocusNodeAdjacency
'
,
seriesId
:
self
.
_model
.
id
});
_clearTimer
()
{
if
(
this
.
_unfocusDelayTimer
)
{
clearTimeout
(
this
.
_unfocusDelayTimer
);
this
.
_unfocusDelayTimer
=
null
;
}
}
focusNodeAdjacency
(
...
...
@@ -335,27 +300,27 @@ class GraphView extends ChartView {
}
graph
.
eachNode
(
function
(
node
)
{
fadeOutItem
(
node
,
nodeOpacityPath
,
0.1
);
fadeOutItem
(
node
);
});
graph
.
eachEdge
(
function
(
edge
)
{
fadeOutItem
(
edge
,
lineOpacityPath
,
0.1
);
fadeOutItem
(
edge
);
});
if
(
node
)
{
fadeInItem
(
node
,
nodeOpacityPath
);
fadeInItem
(
node
);
zrUtil
.
each
(
node
.
edges
,
function
(
adjacentEdge
)
{
if
(
adjacentEdge
.
dataIndex
<
0
)
{
return
;
}
fadeInItem
(
adjacentEdge
,
lineOpacityPath
);
fadeInItem
(
adjacentEdge
.
node1
,
nodeOpacityPath
);
fadeInItem
(
adjacentEdge
.
node2
,
nodeOpacityPath
);
fadeInItem
(
adjacentEdge
);
fadeInItem
(
adjacentEdge
.
node1
);
fadeInItem
(
adjacentEdge
.
node2
);
});
}
if
(
edge
)
{
fadeInItem
(
edge
,
lineOpacityPath
);
fadeInItem
(
edge
.
node1
,
nodeOpacityPath
);
fadeInItem
(
edge
.
node2
,
nodeOpacityPath
);
fadeInItem
(
edge
);
fadeInItem
(
edge
.
node1
);
fadeInItem
(
edge
.
node2
);
}
}
...
...
@@ -365,10 +330,10 @@ class GraphView extends ChartView {
const
graph
=
seriesModel
.
getData
().
graph
;
graph
.
eachNode
(
function
(
node
)
{
fade
OutItem
(
node
,
nodeOpacityPath
);
fade
InItem
(
node
);
});
graph
.
eachEdge
(
function
(
edge
)
{
fade
OutItem
(
edge
,
lineOpacityPath
);
fade
InItem
(
edge
);
});
}
...
...
src/chart/helper/Line.ts
浏览文件 @
2e2a76e8
...
...
@@ -182,6 +182,10 @@ class Line extends graphic.Group {
this
.
_updateCommonStl
(
lineData
,
idx
,
seriesScope
);
};
getLinePath
()
{
return
this
.
childAt
(
0
)
as
graphic
.
Line
;
}
_updateCommonStl
(
lineData
:
List
,
idx
:
number
,
seriesScope
?:
LineDrawSeriesScope
)
{
const
seriesModel
=
lineData
.
hostModel
as
SeriesModel
;
...
...
src/chart/helper/Symbol.ts
浏览文件 @
2e2a76e8
...
...
@@ -95,7 +95,7 @@ class Symbol extends graphic.Group {
* @param {boolean} toLastFrame
*/
stopSymbolAnimation
(
toLastFrame
:
boolean
)
{
this
.
childAt
(
0
).
stopAnimation
(
toLastFrame
);
this
.
childAt
(
0
).
stopAnimation
(
''
,
toLastFrame
);
}
/**
...
...
src/component/helper/roamHelper.ts
浏览文件 @
2e2a76e8
...
...
@@ -22,7 +22,7 @@ import Element from 'zrender/src/Element';
interface
ControllerHost
{
target
:
Element
,
zoom
?:
number
zoomLimit
?:
{
min
:
number
,
max
:
number
}
zoomLimit
?:
{
min
?:
number
,
max
?
:
number
}
}
/**
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录