Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
半栈学徒
incubator-echarts
提交
f9307c75
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,体验更适合开发者的 AI 搜索 >>
提交
f9307c75
编写于
7月 10, 2020
作者:
P
pissang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(map): fix label not display on map
上级
e64f712e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
19 addition
and
59 deletion
+19
-59
src/chart/map/MapView.ts
src/chart/map/MapView.ts
+17
-51
src/component/helper/MapDraw.ts
src/component/helper/MapDraw.ts
+0
-2
src/util/graphic.ts
src/util/graphic.ts
+2
-6
未找到文件。
src/chart/map/MapView.ts
浏览文件 @
f9307c75
...
...
@@ -18,36 +18,22 @@
*/
import
*
as
zrUtil
from
'
zrender/src/core/util
'
;
import
*
as
graphic
from
'
../../util/graphic
'
;
import
MapDraw
from
'
../../component/helper/MapDraw
'
;
import
ChartView
from
'
../../view/Chart
'
;
import
MapSeries
,
{
MapDataItemOption
}
from
'
./MapSeries
'
;
import
GlobalModel
from
'
../../model/Global
'
;
import
ExtensionAPI
from
'
../../ExtensionAPI
'
;
import
{
Payload
}
from
'
../../util/types
'
;
import
{
Payload
,
DisplayState
,
ECElement
}
from
'
../../util/types
'
;
import
Model
from
'
../../model/Model
'
;
const
HIGH_DOWN_PROP
=
'
__seriesMapHighDown
'
as
const
;
const
RECORD_VERSION_PROP
=
'
__seriesMapCallKey
'
as
const
;
const
ORIGINAL_Z2
=
'
__mapOriginalZ2
'
as
const
;
interface
CircleExtend
extends
graphic
.
Circle
{
[
ORIGINAL_Z2
]:
number
;
}
interface
HighDownRecord
{
recordVersion
:
number
;
circle
:
CircleExtend
;
labelModel
:
Model
;
hoverLabelModel
:
Model
;
emphasisText
:
string
;
normalText
:
string
;
};
interface
RegionGroupExtend
extends
graphic
.
Group
{
[
HIGH_DOWN_PROP
]:
HighDownRecord
;
[
RECORD_VERSION_PROP
]:
number
;
}
class
MapView
extends
ChartView
{
...
...
@@ -175,7 +161,7 @@ class MapView extends ChartView {
const
labelModel
=
itemModel
.
getModel
(
'
label
'
);
const
hoverLabelModel
=
itemModel
.
getModel
([
'
emphasis
'
,
'
label
'
]);
const
regionGroup
=
fullData
.
getItemGraphicEl
(
fullIndex
)
as
RegionGroupExtend
;
const
regionGroup
=
fullData
.
getItemGraphicEl
(
fullIndex
);
// `getFormattedLabel` needs to use `getData` inside. Here
// `mapModel.getData()` is shallow cloned from `mainSeries.getData()`.
...
...
@@ -184,43 +170,23 @@ class MapView extends ChartView {
// set on original data item will never get. But it has been working
// like that from the begining, and this scenario is rarely encountered.
// So it won't be fixed until have to.
const
normalText
=
zrUtil
.
retrieve2
(
mapModel
.
getFormattedLabel
(
fullIndex
,
'
normal
'
),
name
);
const
emphasisText
=
zrUtil
.
retrieve2
(
mapModel
.
getFormattedLabel
(
fullIndex
,
'
emphasis
'
),
normalText
);
let
highDownRecord
=
regionGroup
[
HIGH_DOWN_PROP
];
const
recordVersion
=
Math
.
random
();
// Prevent from register listeners duplicatedly when roaming.
if
(
!
highDownRecord
)
{
highDownRecord
=
regionGroup
[
HIGH_DOWN_PROP
]
=
{}
as
HighDownRecord
;
// let onEmphasis = zrUtil.curry(onRegionHighDown, true);
// let onNormal = zrUtil.curry(onRegionHighDown, false);
// regionGroup.on('mouseover', onEmphasis)
// .on('mouseout', onNormal)
// .on('emphasis', onEmphasis)
// .on('normal', onNormal);
}
// Prevent removed regions effect current grapics.
regionGroup
[
RECORD_VERSION_PROP
]
=
recordVersion
;
zrUtil
.
extend
(
highDownRecord
,
{
recordVersion
,
circle
,
labelModel
,
hoverLabelModel
,
emphasisText
,
normalText
}
as
HighDownRecord
);
graphic
.
setLabelStyle
(
circle
,
labelModel
,
hoverLabelModel
,
{
labelFetcher
:
{
getFormattedLabel
(
idx
:
number
,
state
:
DisplayState
)
{
return
mapModel
.
getFormattedLabel
(
fullIndex
,
state
);
}
}
});
if
(
!
labelModel
.
get
(
'
position
'
))
{
circle
.
setTextConfig
({
position
:
'
bottom
'
});
}
// FIXME
// Consider set option when emphasis.
// enterRegionHighDown(highDownRecord, false)
;
(
regionGroup
as
ECElement
).
onStateChange
=
function
(
fromState
,
toState
)
{
circle
.
useState
(
toState
);
}
;
}
group
.
add
(
circle
);
...
...
src/component/helper/MapDraw.ts
浏览文件 @
f9307c75
...
...
@@ -329,8 +329,6 @@ class MapDraw {
scaleY
:
1
/
targetScaleY
},
mapOrGeoModel
);
}
regionGroup
.
add
(
textEl
);
}
// setItemGraphicEl, setHoverStyle after all polygons and labels
...
...
src/util/graphic.ts
浏览文件 @
f9307c75
...
...
@@ -112,7 +112,6 @@ type ExtendedProps = {
__highByOuter
:
number
__highDownSilentOnTouch
:
boolean
__onStateChange
:
(
fromState
:
DisplayState
,
toState
:
DisplayState
)
=>
void
__highDownDispatcher
:
boolean
};
...
...
@@ -389,7 +388,7 @@ function singleLeaveEmphasis(el: Element) {
}
function
updateElementState
<
T
>
(
el
:
E
xtended
Element
,
el
:
E
C
Element
,
updater
:
(
this
:
void
,
el
:
Element
,
commonParam
?:
T
)
=>
void
,
commonParam
?:
T
)
{
...
...
@@ -401,7 +400,7 @@ function updateElementState<T>(
(
el
as
ECElement
).
highlighted
&&
(
fromState
=
EMPHASIS
,
trigger
=
true
);
updater
(
el
,
commonParam
);
(
el
as
ECElement
).
highlighted
&&
(
toState
=
EMPHASIS
,
trigger
=
true
);
trigger
&&
el
.
__onStateChange
&&
el
.
__
onStateChange
(
fromState
,
toState
);
trigger
&&
el
.
onStateChange
&&
el
.
onStateChange
(
fromState
,
toState
);
}
function
traverseUpdateState
<
T
>
(
...
...
@@ -616,9 +615,6 @@ export function setAsHighDownDispatcher(el: Element, asDispatcher: boolean) {
if
((
el
as
ECElement
).
highDownSilentOnTouch
)
{
extendedEl
.
__highDownSilentOnTouch
=
(
el
as
ECElement
).
highDownSilentOnTouch
;
}
if
((
el
as
ECElement
).
onStateChange
)
{
extendedEl
.
__onStateChange
=
(
el
as
ECElement
).
onStateChange
;
}
// Simple optimize, since this method might be
// called for each elements of a group in some cases.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录