Fri Jul 21 23:36:00 CST 2023 inscode

上级 63f8c269
...@@ -21,8 +21,8 @@ ...@@ -21,8 +21,8 @@
<div style="display:flex"> <div style="display:flex">
<div id="barChartId" style="flex:1;width:600px;height:900px;border: 1px solid #333;"> <div id="barChartId" style="flex:1;width:600px;height:900px;border: 1px solid #333;">
<div style="width: 100%;font-weight: 600;text-align: center;">{{ state.clickCity }}</div> <div style="width: 100%;min-width:600px;font-weight: 600;text-align: center;">{{ state.clickCity }}</div>
<div id="barChartId" style="width:600px;height:600px;margin: 0 auto;"> <div id="barChartId" style="min-width:600px;height:600px;margin: 0 auto;">
</div> </div>
</div> </div>
...@@ -45,7 +45,7 @@ import Author from './Author.vue' ...@@ -45,7 +45,7 @@ import Author from './Author.vue'
import gameJson from './gameJson.js'; import gameJson from './gameJson.js';
import { tableGameColumns } from './const.js' import { tableGameColumns } from './const.js'
import * as echarts from 'echarts'; import * as echarts from 'echarts';
import { defineProps, reactive, watch, nextTick, onUnmounted, onMounted } from 'vue'; import { defineProps, reactive, onBeforeMount, onUnmounted, onMounted } from 'vue';
const props = defineProps({ const props = defineProps({
tableData: [] tableData: []
}) })
...@@ -53,7 +53,7 @@ const props = defineProps({ ...@@ -53,7 +53,7 @@ const props = defineProps({
const state = reactive({ const state = reactive({
title: 'vue3 ts antd 参赛选手所在城市', title: 'vue3 ts antd 参赛选手所在城市',
clickCity: '全国', clickCity: '全国',
maxCityNum:0, maxCityNum: 0,
totlaNum: '', totlaNum: '',
linesCoord: [], linesCoord: [],
focusCity: '广东省', focusCity: '广东省',
...@@ -130,10 +130,11 @@ function filterMapName(name) { ...@@ -130,10 +130,11 @@ function filterMapName(name) {
}) })
return res return res
} }
onBeforeMount(() => {
echarts.registerMap('chinaJson', chinaJson)
})
function initMap() { function initMap() {
echarts.registerMap('chinaJson', chinaJson)
let itemData = chinaJson.features let itemData = chinaJson.features
let length = itemData.length let length = itemData.length
state.aimPointData = [] state.aimPointData = []
...@@ -153,12 +154,12 @@ function initMap() { ...@@ -153,12 +154,12 @@ function initMap() {
for (let loc = 0; loc < length; ++loc) { for (let loc = 0; loc < length; ++loc) {
let name = itemData[loc].properties.name let name = itemData[loc].properties.name
console.log('name',name) console.log('name', name)
let number = 0 let number = 0
let center = itemData[loc].properties.center let center = itemData[loc].properties.center
Object.keys(gameJson).forEach(uid => { Object.keys(gameJson).forEach(uid => {
const locName = gameJson[uid].ip.split('')[1] const locName = gameJson[uid].ip.split('')[1]
if (name&&name.includes(locName)) { if (name && name.includes(locName)) {
number += 1 number += 1
} }
}) })
...@@ -180,11 +181,12 @@ function initMap() { ...@@ -180,11 +181,12 @@ function initMap() {
} }
state.airData.push(temp) state.airData.push(temp)
} }
if(state.maxCityNum<number){ if (state.maxCityNum < number) {
state.maxCityNum=number state.maxCityNum = number
} }
continue continue
} }
console.log('state.maxCityNum', state.maxCityNum)
renderEchartBar() renderEchartBar()
} }
...@@ -198,16 +200,7 @@ function changePageSize(current, pageSize) { ...@@ -198,16 +200,7 @@ function changePageSize(current, pageSize) {
state.pagination.current = current state.pagination.current = current
state.pagination.pageSize = pageSize state.pagination.pageSize = pageSize
} }
// watch(() => props.tableData,
// (val) => {
// state.dataSource = val
// nextTick(() => {
// renderEchartBar()
// })
// }, {
// deep: true,
// immediate: true
// })
function renderEchartBar() { function renderEchartBar() {
// 基于准备好的dom,初始化echarts实例 // 基于准备好的dom,初始化echarts实例
const domInstance = document.getElementById('barChartId') const domInstance = document.getElementById('barChartId')
...@@ -223,6 +216,16 @@ function renderEchartBar() { ...@@ -223,6 +216,16 @@ function renderEchartBar() {
text: '中国地图', text: '中国地图',
subtext: 'chinaJson' subtext: 'chinaJson'
}, },
visualMap: { // 设置视觉映射
min: 0,
max: 20,
text: ['最高', '最低'],
realtime: true,
calculable: true,
inRange: {
color: ['lightskyblue', 'yellow', 'orangered']
}
},
geo: { geo: {
// 经纬度中心 // 经纬度中心
// center: state.centerLoction, // center: state.centerLoction,
...@@ -271,16 +274,6 @@ function renderEchartBar() { ...@@ -271,16 +274,6 @@ function renderEchartBar() {
人员信息:<br>${strInfo}` 人员信息:<br>${strInfo}`
} }
}, },
visualMap: { // 设置视觉映射
min: 0,
max: state.maxCityNum,
text: ['最高', '最低'],
realtime: true,
calculable: true,
inRange: {
color: ['lightskyblue', 'yellow', 'orangered']
}
},
series: [ series: [
// 坐标点的热力数据 // 坐标点的热力数据
{ {
...@@ -292,8 +285,8 @@ function renderEchartBar() { ...@@ -292,8 +285,8 @@ function renderEchartBar() {
normal: { normal: {
areaColor: "rgba(0, 0, 0, 0)", areaColor: "rgba(0, 0, 0, 0)",
borderWidth: 8, //设置外层边框 borderWidth: 8, //设置外层边框
borderColor: "#00FFD7", borderColor: "rgba(135,235, 45, 1)",
shadowColor: "rgba(63, 236, 209, 1)", shadowColor: "rgba(135,235, 45, 1)",
shadowBlur: 40, //地图外层光晕 shadowBlur: 40, //地图外层光晕
}, },
}, },
...@@ -343,14 +336,6 @@ function renderEchartBar() { ...@@ -343,14 +336,6 @@ function renderEchartBar() {
data: state.linesCoord data: state.linesCoord
} }
], ],
visualMap: {
min: 0,
max: 100,
inRange: {
color: ['rgba(255,255,255,.7)', 'rgba(63, 236, 209, 1)'] // 控制颜色渐变的范围
},
calculable: false // 出现滑块
}
} }
// 使用刚指定的配置项和数据显示图表。 // 使用刚指定的配置项和数据显示图表。
myChart.setOption(option, true); myChart.setOption(option, true);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册