Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
x649585723
incubator-echarts
提交
19bc6755
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,发现更多精彩内容 >>
提交
19bc6755
编写于
7月 07, 2020
作者:
P
pissang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(state): support blur others when highlight through dispatchAction
上级
1a17fe27
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
74 addition
and
32 deletion
+74
-32
src/echarts.ts
src/echarts.ts
+39
-3
src/util/states.ts
src/util/states.ts
+35
-29
未找到文件。
src/echarts.ts
浏览文件 @
19bc6755
...
...
@@ -38,7 +38,14 @@ import SeriesModel, { SeriesModelConstructor } from './model/Series';
import
ComponentView
,
{
ComponentViewConstructor
}
from
'
./view/Component
'
;
import
ChartView
,
{
ChartViewConstructor
}
from
'
./view/Chart
'
;
import
*
as
graphic
from
'
./util/graphic
'
;
import
{
enterEmphasisWhenMouseOver
,
leaveEmphasisWhenMouseOut
,
isHighDownDispatcher
,
HOVER_STATE_EMPHASIS
,
HOVER_STATE_BLUR
,
toggleOthersBlurStates
}
from
'
./util/states
'
;
import
{
enterEmphasisWhenMouseOver
,
leaveEmphasisWhenMouseOut
,
isHighDownDispatcher
,
HOVER_STATE_EMPHASIS
,
HOVER_STATE_BLUR
,
toggleSeriesBlurStates
}
from
'
./util/states
'
;
import
*
as
modelUtil
from
'
./util/model
'
;
import
{
throttle
}
from
'
./util/throttle
'
;
import
{
seriesStyleTask
,
dataStyleTask
,
dataColorPaletteTask
}
from
'
./visual/style
'
;
...
...
@@ -1296,9 +1303,35 @@ class ECharts extends Eventful {
excludeSeriesIdMap
=
zrUtil
.
createHashMap
(
modelUtil
.
normalizeToArray
(
excludeSeriesId
));
}
const
isHighlight
=
payload
.
type
===
'
highlight
'
;
const
isDownplay
=
payload
.
type
===
'
downplay
'
;
// If dispatchAction before setOption, do nothing.
ecModel
&&
ecModel
.
eachComponent
(
condition
,
function
(
model
)
{
if
(
!
excludeSeriesIdMap
||
excludeSeriesIdMap
.
get
(
model
.
id
)
==
null
)
{
if
(
isHighlight
||
isDownplay
)
{
if
(
model
instanceof
SeriesModel
)
{
const
seriesIndex
=
model
.
seriesIndex
;
const
data
=
model
.
getData
(
payload
.
dataType
);
let
dataIndex
=
modelUtil
.
queryDataIndex
(
data
,
payload
);
// Pick the first one if there is multiple/none exists.
dataIndex
=
(
zrUtil
.
isArray
(
dataIndex
)
?
dataIndex
[
0
]
:
dataIndex
)
||
0
;
let
el
=
data
.
getItemGraphicEl
(
dataIndex
as
number
);
if
(
!
el
)
{
let
count
=
data
.
count
();
let
current
=
0
;
// If data on dataIndex is NaN.
while
(
!
el
&&
current
<
count
)
{
el
=
data
.
getItemGraphicEl
(
current
++
);
}
}
if
(
el
)
{
const
ecData
=
graphic
.
getECData
(
el
);
toggleSeriesBlurStates
(
seriesIndex
,
ecData
.
focus
,
ecData
.
blurScope
,
ecIns
,
isHighlight
);
}
}
}
callView
(
ecIns
[
mainType
===
'
series
'
?
'
_chartsMap
'
:
'
_componentsMap
'
][
model
.
__viewId
]);
...
...
@@ -1682,7 +1715,9 @@ class ECharts extends Eventful {
const
el
=
e
.
target
;
const
dispatcher
=
getHighDownDispatcher
(
el
);
if
(
dispatcher
)
{
toggleOthersBlurStates
(
el
,
ecIns
,
true
);
const
ecData
=
graphic
.
getECData
(
el
);
// Try blur all in the related series. Then emphasis the hoverred.
toggleSeriesBlurStates
(
ecData
.
seriesIndex
,
ecData
.
focus
,
ecData
.
blurScope
,
ecIns
,
true
);
enterEmphasisWhenMouseOver
(
dispatcher
,
e
);
markStatusToUpdate
(
ecIns
);
...
...
@@ -1691,7 +1726,8 @@ class ECharts extends Eventful {
const
el
=
e
.
target
;
const
dispatcher
=
getHighDownDispatcher
(
el
);
if
(
dispatcher
)
{
toggleOthersBlurStates
(
el
,
ecIns
,
false
);
const
ecData
=
graphic
.
getECData
(
el
);
toggleSeriesBlurStates
(
ecData
.
seriesIndex
,
ecData
.
focus
,
ecData
.
blurScope
,
ecIns
,
false
);
leaveEmphasisWhenMouseOut
(
dispatcher
,
e
);
...
...
src/util/states.ts
浏览文件 @
19bc6755
...
...
@@ -266,43 +266,49 @@ function shouldSilent(el: Element, e: ElementEvent) {
return
(
el
as
ExtendedElement
).
__highDownSilentOnTouch
&&
e
.
zrByTouch
;
}
export
function
toggleOthersBlurStates
(
el
:
Element
,
ecIns
:
EChartsType
,
isBlur
:
boolean
)
{
const
model
=
ecIns
.
getModel
();
const
ecData
=
getECData
(
el
);
const
focus
=
ecData
.
focus
;
const
blurScope
=
ecData
.
blurScope
||
'
coordinateSystem
'
;
if
(
!
focus
||
focus
===
'
none
'
)
{
export
function
toggleSeriesBlurStates
(
targetSeriesIndex
:
number
,
focus
:
string
,
blurScope
:
BlurScope
,
ecIns
:
EChartsType
,
isBlur
:
boolean
)
{
if
(
targetSeriesIndex
==
null
)
{
return
;
}
const
dataIndex
=
ecData
.
dataIndex
;
const
seriesIndex
=
ecData
.
seriesIndex
;
const
model
=
ecIns
.
getModel
();
blurScope
=
blurScope
||
'
coordinateSystem
'
;
if
(
!
(
focus
===
'
series
'
||
focus
===
'
self
'
))
{
return
;
}
model
.
eachSeries
(
function
(
seriesModel
)
{
const
view
=
ecIns
.
getViewOfSeriesModel
(
seriesModel
)
;
view
.
group
.
traverse
(
function
(
child
)
{
// TODO getECData will mount an empty object on the element.
// DON'T mount on all elements?
const
otherECData
=
getECData
(
child
);
if
(
otherECData
.
dataIndex
!=
null
)
{
if
(
isBlur
)
{
const
sameSeries
=
seriesIndex
===
otherECData
.
seriesIndex
;
const
differentDataIndex
=
dataIndex
!==
otherECData
.
dataIndex
;
if
(
(
blurScope
===
'
series
'
&&
focus
===
'
self
'
&&
sameSeries
&&
differentDataIndex
)
// Blur others in the same series.
||
(
focus
===
'
self
'
&&
(
!
sameSeries
||
differentDataIndex
))
// Blur all others
||
(
focus
===
'
series
'
&&
!
sameSeries
)
// Blur all other series
)
{
const
sameSeries
=
targetSeriesIndex
===
seriesModel
.
seriesIndex
;
if
(
!
(
blurScope
===
'
series
'
&&
!
sameSeries
// Not blur other series if blurScope series
||
focus
===
'
series
'
&&
sameSeries
// Not blur self series if focus is series.
// TODO blurScope: coordinate system
)
)
{
const
view
=
ecIns
.
getViewOfSeriesModel
(
seriesModel
);
view
.
group
.
traverse
(
function
(
child
)
{
// TODO getECData will mount an empty object on the element.
// DON'T mount on all elements?
const
otherECData
=
getECData
(
child
);
// TODO distinguish edge data in graph.
if
(
otherECData
.
dataIndex
!=
null
)
{
if
(
isBlur
)
{
traverseUpdateState
((
child
as
ExtendedElement
),
singleEnterBlur
);
}
else
{
traverseUpdateState
((
child
as
ExtendedElement
),
singleLeaveBlur
);
}
// No need to traverse the children.
return
true
;
}
else
{
traverseUpdateState
((
child
as
ExtendedElement
),
singleLeaveBlur
);
}
// No need to traverse the children.
return
true
;
}
});
});
}
});
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录