|
@@ -9,36 +9,35 @@
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
|
-import echartsMapList from "./mock.json"
|
|
|
-import beijing from "./beijing.json"
|
|
|
-import {onMounted, reactive, ref} from "vue";
|
|
|
+import echartsMapList from "./mockData/mock.json"
|
|
|
+import {onMounted, ref} from "vue";
|
|
|
import * as echarts from "echarts";
|
|
|
+import {allCity} from "/@/views/admin/visualization/digitalMap/mockData/allCity";
|
|
|
+import router from "/@/router";
|
|
|
|
|
|
// 定义变量内容
|
|
|
const echartsMapRef = ref<RefType>('')
|
|
|
|
|
|
|
|
|
-const mapdata = [{
|
|
|
- 'name': '广东省',
|
|
|
- 'id': 1,
|
|
|
- 'value': 10
|
|
|
-},{
|
|
|
+const mapData = allCity
|
|
|
|
|
|
-}]
|
|
|
-// 注册石家庄地图
|
|
|
+// 注册中国地图
|
|
|
echarts.registerMap('echartsMapList', echartsMapList)
|
|
|
-echarts.registerMap('beijing', beijing)
|
|
|
// 初始化
|
|
|
// option配置
|
|
|
|
|
|
-console.log(echartsMapList)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
const initEchartsMap = () => {
|
|
|
const myChart = echarts.init(echartsMapRef.value)
|
|
|
const option = {
|
|
|
backgroundColor: 'transparent',
|
|
|
title: {
|
|
|
- text: '示范基地数字地图',
|
|
|
+ text: '国内销售数量',
|
|
|
left: 'center',
|
|
|
textStyle: {
|
|
|
color: '#000'
|
|
@@ -48,11 +47,11 @@ const initEchartsMap = () => {
|
|
|
// layoutSize:'130%',//大小
|
|
|
tooltip: {
|
|
|
trigger: 'item',
|
|
|
- formatter: '{b}<br/>{c}台'
|
|
|
+ formatter: (params) => params.name
|
|
|
},
|
|
|
visualMap: {
|
|
|
- min: 800,
|
|
|
- max: 50000,
|
|
|
+ min: 0,
|
|
|
+ max: 50,
|
|
|
text: ['High', 'Low'],
|
|
|
realtime: false,
|
|
|
calculable: true,
|
|
@@ -62,12 +61,12 @@ const initEchartsMap = () => {
|
|
|
},
|
|
|
series: [
|
|
|
{
|
|
|
- name: '香港18区人口密度',
|
|
|
+ name: '国内销售数量',
|
|
|
type: 'map',
|
|
|
map: 'echartsMapList',
|
|
|
label: {
|
|
|
show: true,
|
|
|
- fontSize:14,
|
|
|
+ fontSize:12,
|
|
|
formatter:(params) => {
|
|
|
if(params.value){
|
|
|
return params.name+':'+params.value
|
|
@@ -82,27 +81,29 @@ const initEchartsMap = () => {
|
|
|
//滚轮缩放的极限控制
|
|
|
min: 1, //缩放最小大小
|
|
|
},
|
|
|
- data:mapdata
|
|
|
+ data:mapData,
|
|
|
}
|
|
|
]
|
|
|
}
|
|
|
- let myZoom = 0;
|
|
|
myChart.setOption(option)
|
|
|
myChart.on('georoam',(params) => {
|
|
|
if('dy' in params|| 'dx' in params) return
|
|
|
- myZoom = myChart.getOption().series[0].zoom
|
|
|
+ const myOption = myChart.getOption()
|
|
|
+ const myZoom = myOption.series[0].zoom
|
|
|
if(myZoom > 1.5){
|
|
|
- option.series[0].label.fontSize = 20
|
|
|
- }else if(myZoom > 1){
|
|
|
- option.series[0].label.fontSize = 14
|
|
|
+ myOption.series[0].label.fontSize = 20
|
|
|
+ }else if(myZoom > 1.1){
|
|
|
+ myOption.series[0].label.fontSize = 12
|
|
|
}else {
|
|
|
- option.series[0].label.fontSize = 10
|
|
|
+ myOption.series[0].label.fontSize = 10
|
|
|
}
|
|
|
- delete option.series[0].top
|
|
|
- delete option.series[0].zoom
|
|
|
- myChart.setOption(option)
|
|
|
- // console.log(params)
|
|
|
+ delete myOption.series[0].top
|
|
|
+ delete myOption.series[0].zoom
|
|
|
+ myChart.setOption(myOption)
|
|
|
})
|
|
|
+ myChart.on('click', (e) => {
|
|
|
+ router.push({path:`/admin/visualization/cityLevelMap/${e.data.code}/${e.data.name}`})
|
|
|
+ });
|
|
|
window.addEventListener('resize', () => {
|
|
|
myChart.resize()
|
|
|
})
|
|
@@ -112,11 +113,14 @@ onMounted(() => {
|
|
|
initEchartsMap()
|
|
|
})
|
|
|
|
|
|
+
|
|
|
+
|
|
|
</script>
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
.to-flex {
|
|
|
display: flex;
|
|
|
flex-direction: row;
|
|
|
+ z-index: 999;
|
|
|
}
|
|
|
</style>
|