Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
x649585723
incubator-echarts
提交
f2c35faa
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,体验更适合开发者的 AI 搜索 >>
提交
f2c35faa
编写于
3月 12, 2021
作者:
1
100pah
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: [geo] tweak a little.
上级
30c861cc
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
142 addition
and
50 deletion
+142
-50
src/component/geo/GeoView.ts
src/component/geo/GeoView.ts
+5
-5
src/component/helper/MapDraw.ts
src/component/helper/MapDraw.ts
+5
-0
src/coord/geo/GeoModel.ts
src/coord/geo/GeoModel.ts
+18
-3
test/geo-svg.html
test/geo-svg.html
+114
-42
未找到文件。
src/component/geo/GeoView.ts
浏览文件 @
f2c35faa
...
...
@@ -25,6 +25,7 @@ import ExtensionAPI from '../../core/ExtensionAPI';
import
GeoModel
from
'
../../coord/geo/GeoModel
'
;
import
{
Payload
,
ZRElementEvent
,
ECEventData
}
from
'
../../util/types
'
;
import
{
getECData
}
from
'
../../util/innerStore
'
;
import
{
findEventDispatcher
}
from
'
../../util/event
'
;
class
GeoView
extends
ComponentView
{
...
...
@@ -66,12 +67,11 @@ class GeoView extends ComponentView {
}
private
_handleRegionClick
(
e
:
ZRElementEvent
)
{
let
current
=
e
.
target
;
let
eventData
:
ECEventData
;
// TODO extract a util function
while
(
current
&&
(
eventData
=
getECData
(
current
).
eventData
)
==
null
)
{
current
=
current
.
__hostTarget
||
current
.
parent
;
}
findEventDispatcher
(
e
.
target
,
current
=>
{
return
(
eventData
=
getECData
(
current
).
eventData
)
!=
null
;
}
,
true
);
if
(
eventData
)
{
this
.
_api
.
dispatchAction
({
...
...
src/component/helper/MapDraw.ts
浏览文件 @
f2c35faa
...
...
@@ -403,6 +403,11 @@ class MapDraw {
if
(
data
)
{
data
.
setItemGraphicEl
(
dataIdx
,
elForStateChange
);
}
// series-map will not trigger "geoselectchange" no matter it is
// based on a declared geo component. Becuause series-map will
// trigger "selectchange". If it trigger both the two events,
// If users call `chart.dispatchAction({type: 'toggleSelect'})`,
// it not easy to also fire event "geoselectchanged".
else
{
const
regionModel
=
mapOrGeoModel
.
getRegionModel
(
regionName
);
// Package custom mouse event for geo component
...
...
src/coord/geo/GeoModel.ts
浏览文件 @
f2c35faa
...
...
@@ -34,7 +34,8 @@ import {
RoamOptionMixin
,
AnimationOptionMixin
,
StatesOptionMixin
,
Dictionary
Dictionary
,
CommonTooltipOption
}
from
'
../../util/types
'
;
import
{
NameMap
}
from
'
./geoTypes
'
;
import
GlobalModel
from
'
../../model/Global
'
;
...
...
@@ -59,7 +60,15 @@ interface GeoLabelFormatterDataParams {
export
interface
RegoinOption
extends
GeoStateOption
,
StatesOptionMixin
<
GeoStateOption
>
{
name
?:
string
selected
?:
boolean
};
tooltip
?:
Partial
<
Pick
<
CommonTooltipOption
<
GeoTooltipFormatterParams
>
,
'
show
'
>>
}
export
interface
GeoTooltipFormatterParams
{
componentType
:
'
geo
'
geoIndex
:
number
name
:
string
$vars
:
[
'
name
'
]
}
export
interface
GeoCommonOptionMixin
extends
RoamOptionMixin
{
// Map name
...
...
@@ -103,6 +112,8 @@ export interface GeoOption extends
selectedMode
?:
'
single
'
|
'
multiple
'
|
boolean
selectedMap
?:
Dictionary
<
boolean
>
tooltip
?:
CommonTooltipOption
<
GeoTooltipFormatterParams
>
}
class
GeoModel
extends
ComponentModel
<
GeoOption
>
{
...
...
@@ -188,7 +199,11 @@ class GeoModel extends ComponentModel<GeoOption> {
}
},
regions
:
[]
regions
:
[],
tooltip
:
{
show
:
false
}
};
init
(
option
:
GeoOption
,
parentModel
:
Model
,
ecModel
:
GlobalModel
):
void
{
...
...
test/geo-svg.html
浏览文件 @
f2c35faa
...
...
@@ -37,14 +37,36 @@ under the License.
<div
id=
"main0"
></div>
<div
id=
"main1"
></div>
<div
id=
"main2"
></div>
<div
id=
"main_pure_geo_json"
></div>
<div
id=
"main_pure_geo_svg"
></div>
<div
id=
"main_pure_map_svg"
></div>
<div
id=
"main_map_geo_svg"
></div>
<script>
function
listenAndPrintSelectChanged
(
chart
)
{
if
(
!
chart
)
{
return
;
}
const
out
=
{
};
chart
.
on
(
'
geoselectchanged
'
,
function
(
params
)
{
out
.
allSelected
=
params
.
allSelected
;
console
.
log
(
'
geoselectechanged
'
);
chart
.
__testHelper
.
updateInfo
(
out
,
'
event
'
);
});
chart
.
on
(
'
selectchanged
'
,
function
(
params
)
{
out
.
selected
=
params
.
selected
;
console
.
log
(
'
selectechanged
'
);
chart
.
__testHelper
.
updateInfo
(
out
,
'
event
'
);
});
}
</script>
<script>
require
([
'
echarts
'
/*, 'map/js/china' */
],
function
(
echarts
)
{
...
...
@@ -70,6 +92,8 @@ under the License.
echarts
.
registerMap
(
'
testGeoJson1
'
,
testGeoJson1
);
option
=
{
tooltip
:
{
},
geo
:
{
map
:
'
testGeoJson1
'
,
roam
:
true
,
...
...
@@ -84,29 +108,19 @@ under the License.
}
};
var
chart
=
testHelper
.
create
(
echarts
,
'
main
0
'
,
{
var
chart
=
testHelper
.
create
(
echarts
,
'
main
_pure_geo_json
'
,
{
title
:
[
'
geoJSON location:
'
,
'
pure geo
geoJSON location:
'
,
'
Should be a square and 80% of canvas height.
'
,
'
At the center of the canvas.
'
],
option
:
option
,
info
:
[]
,
infoKey
:
'
allSelected
'
,
info
:
{}
,
infoKey
:
'
event
'
,
height
:
300
});
if
(
chart
)
{
if
(
chart
)
{
chart
.
on
(
'
geoselectchanged
'
,
function
(
params
)
{
chart
.
__testHelper
.
updateInfo
(
params
.
allSelected
,
'
allSelected
'
);
});
}
}
listenAndPrintSelectChanged
(
chart
);
});
</script>
...
...
@@ -126,6 +140,8 @@ under the License.
});
option
=
{
tooltip
:
{
},
geo
:
{
map
:
'
seatmap
'
,
roam
:
true
,
...
...
@@ -158,27 +174,20 @@ under the License.
// }
};
var
chart
=
testHelper
.
create
(
echarts
,
'
main
1
'
,
{
var
chart
=
testHelper
.
create
(
echarts
,
'
main
_pure_geo_svg
'
,
{
title
:
[
'
geo component with svg resource
'
,
'
pure
geo component with svg resource
'
,
'
click seat: check **allSelected** correct.
'
],
option
:
option
,
info
:
[]
,
infoKey
:
'
allSelected
'
,
info
:
{}
,
infoKey
:
'
event
'
,
height
:
300
// buttons: [{text: 'btn-txt', onclick: function () {}}],
// recordCanvas: true,
});
if
(
chart
)
{
chart
.
on
(
'
geoselectchanged
'
,
function
(
params
)
{
chart
.
__testHelper
.
updateInfo
(
params
.
allSelected
,
'
allSelected
'
);
});
}
listenAndPrintSelectChanged
(
chart
);
});
...
...
@@ -231,27 +240,90 @@ under the License.
}
};
var
chart
=
testHelper
.
create
(
echarts
,
'
main
2
'
,
{
var
chart
=
testHelper
.
create
(
echarts
,
'
main
_pure_map_svg
'
,
{
title
:
[
'
map series with svg resource
'
,
'
pure
map series with svg resource
'
,
'
Hover seat: check **tooltip** correct.
'
],
option
:
option
,
info
:
[]
,
infoKey
:
'
allSelected
'
,
info
:
{}
,
infoKey
:
'
event
'
,
height
:
300
// buttons: [{text: 'btn-txt', onclick: function () {}}],
// recordCanvas: true,
});
if
(
chart
)
{
chart
.
on
(
'
selectchanged
'
,
function
(
params
)
{
chart
.
__testHelper
.
updateInfo
(
params
.
selected
,
'
selected
'
);
});
}
listenAndPrintSelectChanged
(
chart
);
});
});
</script>
<script>
require
([
'
echarts
'
/*, 'map/js/china' */
],
function
(
echarts
)
{
var
option
;
$
.
ajax
({
url
:
'
../../vis-data/map/svg/seats/seatmap-example.svg
'
,
dataType
:
'
text
'
}).
done
(
function
(
svg
)
{
echarts
.
registerMap
(
'
seatmap
'
,
{
svg
:
svg
});
option
=
{
tooltip
:
{
},
geo
:
{
map
:
'
seatmap
'
,
roam
:
true
,
selectedMode
:
'
multiple
'
,
// height: 100,
// zoom: 1.5
emphasis
:
{
label
:
{
textBorderColor
:
'
#fff
'
,
textBorderWidth
:
2
}
},
select
:
{
itemStyle
:
{
color
:
'
#b50205
'
},
label
:
{
show
:
false
,
textBorderColor
:
'
#fff
'
,
textBorderWidth
:
2
}
}
},
series
:
{
type
:
'
map
'
,
selectedMode
:
'
multiple
'
,
coordinateSystem
:
'
geo
'
,
geoIndex
:
0
}
};
var
chart
=
testHelper
.
create
(
echarts
,
'
main_map_geo_svg
'
,
{
title
:
[
'
map series on declared geo with svg resource
'
,
'
Hover seat: check **tooltip** correct.
'
],
option
:
option
,
info
:
{},
infoKey
:
'
event
'
,
height
:
300
// buttons: [{text: 'btn-txt', onclick: function () {}}],
// recordCanvas: true,
});
listenAndPrintSelectChanged
(
chart
);
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录