You need to sign in or sign up before continuing.

Mon Jul 17 10:05:00 CST 2023 inscode

上级 5df37b77
...@@ -4,8 +4,10 @@ ...@@ -4,8 +4,10 @@
<a style="font-size: 24px;font-weight:bolder;">{{ state.title }}</a> <a style="font-size: 24px;font-weight:bolder;">{{ state.title }}</a>
</div> </div>
</div> </div>
<div> <div style="display:flex">
<a-table :scroll="{ x: 800, y: 600 }" :columns="state.columns" :data-source="state.dataSource" <div id="barChartId" style="flex:1;width:600px;height:900px;margin: 0 auto;border: 1px solid #333;"></div>
<div style="width: 700px;height:900px;border: 1px solid #333;">
<a-table :scroll="{ x: 600, y: 750 }" :columns="state.columns" :data-source="state.dataSource"
:loading="state.loading" :pagination="state.pagination" bordered style="border-bottom:1px solid #f0f0f0;"> :loading="state.loading" :pagination="state.pagination" bordered style="border-bottom:1px solid #f0f0f0;">
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
<template v-if="column.key === 'url'"> <template v-if="column.key === 'url'">
...@@ -30,7 +32,8 @@ ...@@ -30,7 +32,8 @@
</template> </template>
</a-table> </a-table>
</div> </div>
<div id="barChartId" style="width:100vw;height:900px;margin: 0 auto"></div>
</div>
</template> </template>
<script setup> <script setup>
import chinaJson from './chinaGeo.js'; import chinaJson from './chinaGeo.js';
...@@ -43,7 +46,7 @@ const props = defineProps({ ...@@ -43,7 +46,7 @@ const props = defineProps({
}) })
const state = reactive({ const state = reactive({
title: '参赛选手所在城市', title: 'python 爬虫赛道 参赛选手所在城市',
linesCoord: [], linesCoord: [],
focusCity: '深圳', focusCity: '深圳',
locationGis: [], locationGis: [],
...@@ -57,8 +60,8 @@ const state = reactive({ ...@@ -57,8 +60,8 @@ const state = reactive({
pagination: { pagination: {
total: 0, total: 0,
current: 1, current: 1,
pageSize: 10, pageSize: 50,
pageSizeOptions: ['10', '50', '100'], pageSizeOptions: ['50', '100', '200'],
showTotal: (total, range) => { showTotal: (total, range) => {
return range[0] + '-' + range[1] + '' + total + '个选手'; return range[0] + '-' + range[1] + '' + total + '个选手';
}, },
...@@ -77,10 +80,26 @@ function initDataSource() { ...@@ -77,10 +80,26 @@ function initDataSource() {
}) })
state.total += 1 state.total += 1
}) })
// map state.pagination.current=1
}
function filterName(name) {
state.dataSource = []
state.total = 0
Object.keys(gameJson).forEach(uid => {
if(name.includes(gameJson[uid].name)){
state.dataSource.push({
uid: gameJson[uid].uid,
name: gameJson[uid].name,
ip: gameJson[uid].ip.split('')[1]
})
state.total += 1
}
})
state.pagination.current=1
} }
function initMap() { function initMap() {
echarts.registerMap('chinaJson', chinaJson) echarts.registerMap('chinaJson', chinaJson)
let itemData = chinaJson.features let itemData = chinaJson.features
...@@ -123,6 +142,10 @@ function initMap() { ...@@ -123,6 +142,10 @@ function initMap() {
} }
continue continue
} }
setTimeout(()=>{
renderEchartBar()
},500)
} }
// storage // storage
...@@ -134,16 +157,16 @@ function changePageSize(current, pageSize) { ...@@ -134,16 +157,16 @@ function changePageSize(current, pageSize) {
state.pagination.current = current state.pagination.current = current
state.pagination.pageSize = pageSize state.pagination.pageSize = pageSize
} }
watch(() => props.tableData, // watch(() => props.tableData,
(val) => { // (val) => {
state.dataSource = val // state.dataSource = val
nextTick(() => { // nextTick(() => {
renderEchartBar() // renderEchartBar()
}) // })
}, { // }, {
deep: true, // deep: true,
immediate: true // immediate: true
}) // })
function renderEchartBar() { function renderEchartBar() {
// 基于准备好的dom,初始化echarts实例 // 基于准备好的dom,初始化echarts实例
const domInstance = document.getElementById('barChartId') const domInstance = document.getElementById('barChartId')
...@@ -161,29 +184,32 @@ function renderEchartBar() { ...@@ -161,29 +184,32 @@ function renderEchartBar() {
}, },
geo: { geo: {
// 经纬度中心 // 经纬度中心
center: state.centerLoction, // center: state.centerLoction,
type: 'map', type: 'map',
map: 'chinaJson', // 这里的值要和上面registerMap的第一个参数一致 map: 'chinaJson', // 这里的值要和上面registerMap的第一个参数一致
roam: true, // 拖拽 roam: false, // 拖拽
nameProperty: 'name', nameProperty: 'name',
// 悬浮标签 // 悬浮标签
label: { label: {
type: 'map', type: 'map',
map: 'chinaJson', // 这里的值要和上面registerMap的第一个参数一致 map: 'chinaJson', // 这里的值要和上面registerMap的第一个参数一致
// roam: false, // 拖拽 // roam: false, // 拖拽
nameProperty: 'name', // nameProperty: 'name',
show: true, show: true,
color: '#fff', color: '#333',
backgroundColor: '#546de5', formatter:function(params){
align: 'center', return params.name
fontSize: 10, },
width: (function () { // backgroundColor: '#546de5',
// let n = parseInt(Math.random() * 10) // align: 'center',
return 110 // fontSize: 10,
})(), // width: (function () {
height: 50, // // let n = parseInt(Math.random() * 10)
shadowColor: 'rgba(0,0,0,.7)', // return 110
borderRadius: 10 // })(),
// height: 50,
// shadowColor: 'rgba(0,0,0,.7)',
// borderRadius: 10
}, },
zoom: 1.2 zoom: 1.2
}, },
...@@ -255,12 +281,8 @@ function renderEchartBar() { ...@@ -255,12 +281,8 @@ function renderEchartBar() {
// 监听 // 监听
state.echartInstance = myChart; state.echartInstance = myChart;
myChart.on('click', function (params) { myChart.on('click', function (params) {
const findItem = state.dataSource.find(item => { console.log('params',params)
return item.postTime == params.name filterName(params.name)
})
if (params.name) {
window.open(findItem.url, '_blank')
}
}); });
window.onresize = myChart.resize; window.onresize = myChart.resize;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册