<template>
<div class="content">
<div ref="mapRef" style="width: 1000px; height: 800px"></div>
</div>
</template>
<script setup lang="ts">
import * as echarts from "echarts";
import zhongguo from "../assets/china.json";
import { onMounted, ref } from "vue";
const mapRef = ref<HTMLDivElement>();
let myChart: echarts.ECharts;
onMounted(() => {
myChart = echarts.init(mapRef.value);
myChart.setOption;
echarts.registerMap("china", zhongguo as any);
const option = {
backgroundColor: "#404a59",
tooltip: {
show: true,
trigger: "item",
alwaysShowContent: false,
backgroundColor: "#0C121C",
borderColor: "rgba(0, 0, 0, 0.16);",
hideDelay: 100,
triggerOn: "mousemove",
enterable: true,
textStyle: {
color: "#DADADA",
fontSize: "12",
width: 20,
height: 30,
overflow: "break",
},
showDelay: 100,
},
geo: {
map: "china",
label: {
normal: {
show: true,
textStyle: {
color: "#fff",
},
},
emphasis: {
textStyle: {
color: "#fff",
},
},
},
itemStyle: {
normal: {
borderColor: "rgba(147, 235, 248, 1)",
borderWidth: 1,
areaColor: {
type: "radial",
x: 0.5,
y: 0.5,
r: 0.8,
colorStops: [
{
offset: 0,
color: "rgba(147, 235, 248, 0)",
},
{
offset: 1,
color: "rgba(147, 235, 248, .2)",
},
],
globalCoord: false,
},
shadowColor: "rgba(128, 217, 248, 1)",
shadowOffsetX: -2,
shadowOffsetY: 2,
shadowBlur: 10,
},
emphasis: {
areaColor: "#389BB7",
borderWidth: 0,
},
},
},
};
myChart.setOption(option);
});
</script>
<style scoped>
.content {
height: 100vh;
width: 100vw;
}
</style>