Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
x649585723
incubator-echarts
提交
6b86fff7
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,发现更多精彩内容 >>
提交
6b86fff7
编写于
5月 19, 2020
作者:
P
pissang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: use highlighted and selected flag to determine if apply state.
上级
e4c13082
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
31 addition
and
15 deletion
+31
-15
src/chart/pie/PieView.ts
src/chart/pie/PieView.ts
+10
-9
src/echarts.ts
src/echarts.ts
+14
-1
src/util/graphic.ts
src/util/graphic.ts
+4
-5
src/util/types.ts
src/util/types.ts
+3
-0
未找到文件。
src/chart/pie/PieView.ts
浏览文件 @
6b86fff7
...
...
@@ -24,7 +24,7 @@ import * as graphic from '../../util/graphic';
import
ChartView
from
'
../../view/Chart
'
;
import
GlobalModel
from
'
../../model/Global
'
;
import
ExtensionAPI
from
'
../../ExtensionAPI
'
;
import
{
Payload
,
ColorString
}
from
'
../../util/types
'
;
import
{
Payload
,
ColorString
,
ECElement
}
from
'
../../util/types
'
;
import
List
from
'
../../data/List
'
;
import
PieSeriesModel
,
{
PieDataItemOption
}
from
'
./PieSeries
'
;
...
...
@@ -45,11 +45,6 @@ function updateDataSelected(
name
:
name
,
seriesId
:
seriesModel
.
id
});
data
.
each
(
function
(
idx
)
{
const
el
=
data
.
getItemGraphicEl
(
idx
);
el
.
toggleState
(
'
select
'
,
seriesModel
.
isSelected
(
data
.
getName
(
idx
)));
});
}
/**
...
...
@@ -166,8 +161,8 @@ class PiePiece extends graphic.Sector {
graphic
.
enableHoverEmphasis
(
this
);
// S
witch after `select` state updated
.
sector
.
toggleState
(
'
select
'
,
seriesModel
.
isSelected
(
data
.
getName
(
idx
)
));
// S
tate will be set after all rendered in the pipeline
.
(
sector
as
ECElement
).
selected
=
seriesModel
.
isSelected
(
data
.
getName
(
idx
));
}
private
_updateLabel
(
data
:
List
,
idx
:
number
,
withAnimation
:
boolean
):
void
{
...
...
@@ -296,11 +291,17 @@ class PieView extends ChartView {
}
render
(
seriesModel
:
PieSeriesModel
,
ecModel
:
GlobalModel
,
api
:
ExtensionAPI
,
payload
:
Payload
):
void
{
const
data
=
seriesModel
.
getData
();
if
(
payload
&&
(
payload
.
from
===
this
.
uid
))
{
// update selected status
data
.
each
(
function
(
idx
)
{
const
el
=
data
.
getItemGraphicEl
(
idx
);
(
el
as
ECElement
).
selected
=
seriesModel
.
isSelected
(
data
.
getName
(
idx
));
});
return
;
}
const
data
=
seriesModel
.
getData
();
const
oldData
=
this
.
_data
;
const
group
=
this
.
group
;
...
...
src/echarts.ts
浏览文件 @
6b86fff7
...
...
@@ -1779,6 +1779,7 @@ class ECharts extends Eventful {
interface
DisplayableWithStatesHistory
extends
Displayable
{
__prevStates
:
string
[]
};
// Clear states without animation.
// TODO States on component.
function
clearStates
(
seriesModel
:
SeriesModel
,
view
:
ChartView
):
void
{
view
.
group
.
traverse
(
function
(
el
:
Displayable
)
{
...
...
@@ -1787,7 +1788,6 @@ class ECharts extends Eventful {
(
el
as
DisplayableWithStatesHistory
).
__prevStates
=
el
.
currentStates
;
const
textContent
=
el
.
getTextContent
();
const
textGuide
=
el
.
getTextGuideLine
();
// Not use animation when clearStates and restore states in `updateStates`
if
(
el
.
stateTransition
)
{
el
.
stateTransition
=
null
;
}
...
...
@@ -1809,6 +1809,7 @@ class ECharts extends Eventful {
// Only updated on changed element. In case element is incremental and don't wan't to rerender.
if
(
el
.
__dirty
&&
el
.
states
&&
el
.
states
.
emphasis
)
{
const
prevStates
=
(
el
as
DisplayableWithStatesHistory
).
__prevStates
;
// Restore states without animation
if
(
prevStates
)
{
el
.
useStates
(
prevStates
);
}
...
...
@@ -1825,6 +1826,18 @@ class ECharts extends Eventful {
graphic
.
setStateTransition
(
textGuide
,
stateAnimationModel
);
}
}
// The use higlighted and selected flag to toggle states.
const
states
=
[];
if
((
el
as
ECElement
).
selected
)
{
states
.
push
(
'
select
'
);
}
if
((
el
as
ECElement
).
highlighted
)
{
states
.
push
(
'
emphasis
'
);
}
el
.
useStates
(
states
);
// el.toggleState('select', (el as ECElement).selected);
// el.toggleState('emphasis', (el as ECElement).highlighted);
}
});
};
...
...
src/util/graphic.ts
浏览文件 @
6b86fff7
...
...
@@ -106,7 +106,6 @@ type ExtendShapeReturn = ReturnType<typeof Path.extend>;
type
ExtendedProps
=
{
__highlighted
?:
boolean
|
'
layer
'
|
'
plain
'
__highByOuter
:
number
__highDownSilentOnTouch
:
boolean
...
...
@@ -371,7 +370,7 @@ function liftColor(color: string): string {
function
singleEnterEmphasis
(
el
:
Element
)
{
(
el
as
E
xtendedElement
).
__
highlighted
=
true
;
(
el
as
E
CElement
).
highlighted
=
true
;
// el may be an array.
if
(
!
el
.
states
.
emphasis
)
{
...
...
@@ -385,7 +384,7 @@ function singleEnterEmphasis(el: Element) {
function
singleLeaveEmphasis
(
el
:
Element
)
{
el
.
removeState
(
'
emphasis
'
);
(
el
as
E
xtendedElement
).
__
highlighted
=
false
;
(
el
as
E
CElement
).
highlighted
=
false
;
}
function
updateElementState
<
T
>
(
...
...
@@ -398,9 +397,9 @@ function updateElementState<T>(
let
toState
:
DisplayState
=
NORMAL
;
let
trigger
;
// See the rule of `onStateChange` on `graphic.setAsHighDownDispatcher`.
el
.
__
highlighted
&&
(
fromState
=
EMPHASIS
,
trigger
=
true
);
(
el
as
ECElement
).
highlighted
&&
(
fromState
=
EMPHASIS
,
trigger
=
true
);
updater
(
el
,
commonParam
);
el
.
__
highlighted
&&
(
toState
=
EMPHASIS
,
trigger
=
true
);
(
el
as
ECElement
).
highlighted
&&
(
toState
=
EMPHASIS
,
trigger
=
true
);
trigger
&&
el
.
__onStateChange
&&
el
.
__onStateChange
(
fromState
,
toState
);
}
...
...
src/util/types.ts
浏览文件 @
6b86fff7
...
...
@@ -106,6 +106,9 @@ export interface ECElement extends Element {
};
highDownSilentOnTouch
?:
boolean
;
onStateChange
?:
(
fromState
:
'
normal
'
|
'
emphasis
'
,
toState
:
'
normal
'
|
'
emphasis
'
)
=>
void
;
highlighted
?:
boolean
;
selected
?:
boolean
;
}
export
interface
DataHost
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录