Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
半栈学徒
incubator-echarts
提交
d5e2375d
I
incubator-echarts
项目概览
半栈学徒
/
incubator-echarts
与 Fork 源项目一致
从无法访问的项目Fork
通知
5
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,发现更多精彩内容 >>
提交
d5e2375d
编写于
7月 18, 2020
作者:
P
pissang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(state): fix can't remove stroke when switching from select,emphasis state to emphasis state.
上级
cc31caa3
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
56 addition
and
35 deletion
+56
-35
src/chart/custom.ts
src/chart/custom.ts
+1
-0
src/util/graphic.ts
src/util/graphic.ts
+0
-5
src/util/states.ts
src/util/states.ts
+54
-30
src/util/types.ts
src/util/types.ts
+1
-0
未找到文件。
src/chart/custom.ts
浏览文件 @
d5e2375d
...
@@ -585,6 +585,7 @@ function createEl(elOption: CustomElementOption): Element {
...
@@ -585,6 +585,7 @@ function createEl(elOption: CustomElementOption): Element {
// some cases probably be broken: hierarchy layout along z, like circle packing,
// some cases probably be broken: hierarchy layout along z, like circle packing,
// where emphasis only intending to modify color/border rather than lift z2.
// where emphasis only intending to modify color/border rather than lift z2.
(
el
as
ECElement
).
z2EmphasisLift
=
1
;
(
el
as
ECElement
).
z2EmphasisLift
=
1
;
(
el
as
ECElement
).
z2SelectLift
=
1
;
return
el
;
return
el
;
}
}
...
...
src/util/graphic.ts
浏览文件 @
d5e2375d
...
@@ -82,11 +82,6 @@ const mathMin = Math.min;
...
@@ -82,11 +82,6 @@ const mathMin = Math.min;
export
const
EMPTY_OBJ
=
{};
export
const
EMPTY_OBJ
=
{};
export
const
Z2_EMPHASIS_LIFT
=
10
;
export
const
_highlightKeyMap
:
Dictionary
<
number
>
=
{};
const
_customShapeMap
:
Dictionary
<
{
new
():
Path
}
>
=
{};
const
_customShapeMap
:
Dictionary
<
{
new
():
Path
}
>
=
{};
type
ExtendShapeOpt
=
Parameters
<
typeof
Path
.
extend
>
[
0
];
type
ExtendShapeOpt
=
Parameters
<
typeof
Path
.
extend
>
[
0
];
...
...
src/util/states.ts
浏览文件 @
d5e2375d
...
@@ -8,11 +8,7 @@ import Element, { ElementEvent } from 'zrender/src/Element';
...
@@ -8,11 +8,7 @@ import Element, { ElementEvent } from 'zrender/src/Element';
import
Model
from
'
../model/Model
'
;
import
Model
from
'
../model/Model
'
;
import
{
DisplayState
,
ECElement
,
ColorString
,
BlurScope
,
InnerFocus
,
Payload
}
from
'
./types
'
;
import
{
DisplayState
,
ECElement
,
ColorString
,
BlurScope
,
InnerFocus
,
Payload
}
from
'
./types
'
;
import
{
extend
,
indexOf
,
isArrayLike
,
isObject
,
keys
,
isArray
}
from
'
zrender/src/core/util
'
;
import
{
extend
,
indexOf
,
isArrayLike
,
isObject
,
keys
,
isArray
}
from
'
zrender/src/core/util
'
;
import
{
import
{
getECData
}
from
'
./graphic
'
;
Z2_EMPHASIS_LIFT
,
getECData
,
_highlightKeyMap
}
from
'
./graphic
'
;
import
*
as
colorTool
from
'
zrender/src/tool/color
'
;
import
*
as
colorTool
from
'
zrender/src/tool/color
'
;
import
{
EChartsType
}
from
'
../echarts
'
;
import
{
EChartsType
}
from
'
../echarts
'
;
import
List
from
'
../data/List
'
;
import
List
from
'
../data/List
'
;
...
@@ -22,7 +18,9 @@ import { queryDataIndex } from './model';
...
@@ -22,7 +18,9 @@ import { queryDataIndex } from './model';
import
{
PathStyleProps
}
from
'
zrender/src/graphic/Path
'
;
import
{
PathStyleProps
}
from
'
zrender/src/graphic/Path
'
;
// Reserve 0 as default.
// Reserve 0 as default.
export
let
_highlightNextDigit
=
1
;
let
_highlightNextDigit
=
1
;
const
_highlightKeyMap
:
Dictionary
<
number
>
=
{};
export
const
HOVER_STATE_NORMAL
:
0
=
0
;
export
const
HOVER_STATE_NORMAL
:
0
=
0
;
export
const
HOVER_STATE_BLUR
:
1
=
1
;
export
const
HOVER_STATE_BLUR
:
1
=
1
;
...
@@ -31,6 +29,9 @@ export const HOVER_STATE_EMPHASIS: 2 = 2;
...
@@ -31,6 +29,9 @@ export const HOVER_STATE_EMPHASIS: 2 = 2;
export
const
SPECIAL_STATES
=
[
'
emphasis
'
,
'
blur
'
,
'
select
'
]
as
const
;
export
const
SPECIAL_STATES
=
[
'
emphasis
'
,
'
blur
'
,
'
select
'
]
as
const
;
export
const
DISPLAY_STATES
=
[
'
normal
'
,
'
emphasis
'
,
'
blur
'
,
'
select
'
]
as
const
;
export
const
DISPLAY_STATES
=
[
'
normal
'
,
'
emphasis
'
,
'
blur
'
,
'
select
'
]
as
const
;
export
const
Z2_EMPHASIS_LIFT
=
10
;
export
const
Z2_SELECT_LIFT
=
9
;
type
ExtendedProps
=
{
type
ExtendedProps
=
{
__highByOuter
:
number
__highByOuter
:
number
...
@@ -177,42 +178,62 @@ function createEmphasisDefaultState(
...
@@ -177,42 +178,62 @@ function createEmphasisDefaultState(
)
{
)
{
const
hasEmphasis
=
indexOf
(
el
.
currentStates
,
stateName
)
>=
0
;
const
hasEmphasis
=
indexOf
(
el
.
currentStates
,
stateName
)
>=
0
;
let
cloned
=
false
;
let
cloned
=
false
;
if
(
!
(
el
instanceof
ZRText
))
{
if
(
!
hasEmphasis
)
{
// Do nothing if there is emphasis state exists.
const
currentFill
=
el
.
style
.
fill
;
if
(
!
(
el
instanceof
ZRText
))
{
const
currentStroke
=
el
.
style
.
stroke
;
const
currentFill
=
el
.
style
.
fill
;
if
(
currentFill
||
currentStroke
)
{
const
currentStroke
=
el
.
style
.
stroke
;
const
fromState
:
PathStyleProps
=
!
hasEmphasis
if
(
currentFill
||
currentStroke
)
{
?
getFromStateStyle
(
el
,
[
'
fill
'
,
'
stroke
'
],
stateName
)
const
fromState
=
getFromStateStyle
(
el
,
[
'
fill
'
,
'
stroke
'
],
stateName
);
:
null
;
state
=
state
||
{};
state
=
state
||
{};
// Apply default color lift
// Apply default color lift
let
emphasisStyle
=
state
.
style
||
{};
let
emphasisStyle
=
state
.
style
||
{};
if
(
!
hasFillOrStroke
(
emphasisStyle
.
fill
)
&&
hasFillOrStroke
(
currentFill
))
{
if
(
!
hasFillOrStroke
(
emphasisStyle
.
fill
)
&&
hasFillOrStroke
(
currentFill
))
{
cloned
=
true
;
cloned
=
true
;
// Not modify the original value.
// Not modify the original value.
state
=
extend
({},
state
);
state
=
extend
({},
state
);
emphasisStyle
=
extend
({},
emphasisStyle
);
emphasisStyle
=
extend
({},
emphasisStyle
);
// Already being applied 'emphasis'. DON'T lift color multiple times.
// Already being applied 'emphasis'. DON'T lift color multiple times.
emphasisStyle
.
fill
=
liftColor
(
fromState
.
fill
as
ColorString
);
emphasisStyle
.
fill
=
hasEmphasis
?
currentFill
:
liftColor
(
fromState
.
fill
as
ColorString
);
}
if
(
!
hasFillOrStroke
(
emphasisStyle
.
stroke
)
&&
hasFillOrStroke
(
currentStroke
))
{
if
(
!
cloned
)
{
state
=
extend
({},
state
);
emphasisStyle
=
extend
({},
emphasisStyle
);
}
emphasisStyle
.
stroke
=
liftColor
(
fromState
.
stroke
as
ColorString
);
}
state
.
style
=
emphasisStyle
;
}
}
if
(
!
hasFillOrStroke
(
emphasisStyle
.
stroke
)
&&
hasFillOrStroke
(
currentStroke
))
{
}
if
(
state
)
{
// TODO Share with textContent?
if
(
state
.
z2
==
null
)
{
if
(
!
cloned
)
{
if
(
!
cloned
)
{
state
=
extend
({},
state
);
state
=
extend
({},
state
);
emphasisStyle
=
extend
({},
emphasisStyle
);
}
}
emphasisStyle
.
stroke
=
hasEmphasis
?
currentStroke
:
liftColor
(
fromState
.
stroke
as
ColorString
);
const
z2EmphasisLift
=
(
el
as
ECElement
).
z2EmphasisLift
;
state
.
z2
=
el
.
z2
+
(
z2EmphasisLift
!=
null
?
z2EmphasisLift
:
Z2_EMPHASIS_LIFT
);
}
}
state
.
style
=
emphasisStyle
;
}
}
}
}
return
state
;
}
function
createSelectDefaultState
(
el
:
Displayable
,
stateName
:
'
select
'
,
state
:
Displayable
[
'
states
'
][
number
]
)
{
const
hasSelect
=
indexOf
(
el
.
currentStates
,
stateName
)
>=
0
;
let
cloned
=
false
;
if
(
state
)
{
if
(
state
)
{
// TODO Share with textContent?
// TODO Share with textContent?
if
(
state
.
z2
==
null
)
{
if
(
state
.
z2
==
null
)
{
if
(
!
cloned
)
{
if
(
!
cloned
)
{
state
=
extend
({},
state
);
state
=
extend
({},
state
);
}
}
const
z2
EmphasisLift
=
(
el
as
ECElement
).
z2Emphasis
Lift
;
const
z2
SelectLift
=
(
el
as
ECElement
).
z2Select
Lift
;
state
.
z2
=
el
.
z2
+
(
z2
EmphasisLift
!=
null
?
z2EmphasisLift
:
Z2_EMPHASIS
_LIFT
);
state
.
z2
=
el
.
z2
+
(
z2
SelectLift
!=
null
?
z2SelectLift
:
Z2_SELECT
_LIFT
);
}
}
}
}
return
state
;
return
state
;
...
@@ -227,7 +248,7 @@ function createBlurDefaultState(
...
@@ -227,7 +248,7 @@ function createBlurDefaultState(
const
currentOpacity
=
el
.
style
.
opacity
;
const
currentOpacity
=
el
.
style
.
opacity
;
const
fromState
=
!
hasBlur
const
fromState
=
!
hasBlur
?
getFromStateStyle
(
el
,
[
'
fill
'
,
'
stroke
'
],
stateName
,
{
?
getFromStateStyle
(
el
,
[
'
opacity
'
],
stateName
,
{
opacity
:
1
opacity
:
1
})
})
:
null
;
:
null
;
...
@@ -256,6 +277,9 @@ function elementStateProxy(this: Displayable, stateName: string): DisplayableSta
...
@@ -256,6 +277,9 @@ function elementStateProxy(this: Displayable, stateName: string): DisplayableSta
else
if
(
stateName
===
'
blur
'
)
{
else
if
(
stateName
===
'
blur
'
)
{
return
createBlurDefaultState
(
this
,
stateName
,
state
);
return
createBlurDefaultState
(
this
,
stateName
,
state
);
}
}
else
if
(
stateName
===
'
select
'
)
{
return
createSelectDefaultState
(
this
,
stateName
,
state
);
}
}
}
return
state
;
return
state
;
}
}
...
...
src/util/types.ts
浏览文件 @
d5e2375d
...
@@ -114,6 +114,7 @@ export interface ECElement extends Element {
...
@@ -114,6 +114,7 @@ export interface ECElement extends Element {
selected
?:
boolean
;
selected
?:
boolean
;
z2EmphasisLift
?:
number
;
z2EmphasisLift
?:
number
;
z2SelectLift
?:
number
;
/**
/**
* Force disable animation on any condition
* Force disable animation on any condition
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录