btgxq-dashuju/src/components/ddzhxt/rysshyqk.vue

169 lines
3.6 KiB
Vue
Raw Normal View History

2023-08-08 16:15:54 +08:00
<template>
<div class="container9" @click="fn(rysshyqkUrl)">
<div ref="line" class="line"></div>
</div>
</template>
2024-04-22 11:16:09 +08:00
2023-08-08 16:15:54 +08:00
<script>
// import '@/utils/echa.js'
import { getRysshyqk } from '@/api/ddzhxt.js'
export default {
2024-04-22 11:16:09 +08:00
data () {
2023-08-08 16:15:54 +08:00
return {
data: [],
times: [],
2024-04-22 11:16:09 +08:00
// number: [], 老数据
// 新数据
bossCount: [],
zgyCount: [],
rysshyqkUrl: 'http://219.147.99.164:8082/servicecity/route/bigdata/list-hour-user-rysshyqk.html'
2023-08-08 16:15:54 +08:00
}
},
computed: {
},
2024-04-22 11:16:09 +08:00
created () {
2023-08-08 16:15:54 +08:00
this.getRysshyqk()
// setTimeout(() => {
// this.gr()
// }, 300);
},
2024-04-22 11:16:09 +08:00
mounted () {
2023-08-08 16:15:54 +08:00
},
watch: {
},
methods: {
2024-04-22 11:16:09 +08:00
fn (url) {
// eslint-disable-next-line no-undef
2023-08-08 16:15:54 +08:00
layer.open({
type: 2,
2024-04-22 11:16:09 +08:00
content: url,
2023-08-08 16:15:54 +08:00
area: ['80%', '80%'],
2024-04-22 11:16:09 +08:00
title: ''
})
2023-08-08 16:15:54 +08:00
},
2024-04-22 11:16:09 +08:00
gr () {
let myChart = this.$echarts.init(this.$refs.line)
2023-08-08 16:15:54 +08:00
// 用于清除定时器
2024-04-22 11:16:09 +08:00
var tootipTimer = null
2023-08-08 16:15:54 +08:00
let option = {
grid: {
2024-04-22 11:16:09 +08:00
left: '3%',
right: '7%',
bottom: '5%',
top: '10%',
containLabel: true
2023-08-08 16:15:54 +08:00
},
xAxis: {
2024-04-22 11:16:09 +08:00
type: 'category',
2023-08-08 16:15:54 +08:00
data: this.times,
axisTick: {
alignWithLabel: true,
lineStyle: {
2024-04-22 11:16:09 +08:00
color: '#fff'
} // x轴刻度的颜色
2023-08-08 16:15:54 +08:00
},
axisLabel: {
textStyle: {
2024-04-22 11:16:09 +08:00
color: '#fff'
}
}
2023-08-08 16:15:54 +08:00
},
yAxis: {
2024-04-22 11:16:09 +08:00
type: 'value',
2023-08-08 16:15:54 +08:00
axisLabel: {
textStyle: {
2024-04-22 11:16:09 +08:00
color: '#fff'
}
2023-08-08 16:15:54 +08:00
},
splitLine: {
show: true,
lineStyle: {
2024-04-22 11:16:09 +08:00
color: '#fff'
}
}
2023-08-08 16:15:54 +08:00
},
tooltip: {
show: true,
borderWidth: 0,
2024-04-22 11:16:09 +08:00
trigger: 'axis',
2023-08-08 16:15:54 +08:00
axisPointer: {
2024-04-22 11:16:09 +08:00
type: 'line'
}
2023-08-08 16:15:54 +08:00
// formatter: function (param) {
// return + param.name ;
// }
},
series: [
{
2024-04-22 11:48:09 +08:00
name: '网格员',
2024-04-22 11:16:09 +08:00
data: this.bossCount,
type: 'line'
// 是否开启平滑
// smooth: true,
// 折线区域是面积及颜色
// areaStyle: {
// color: '#e1e3eb'
// }
2023-08-08 16:15:54 +08:00
},
2024-04-22 11:16:09 +08:00
{
2024-04-22 11:48:09 +08:00
name: '专管员',
2024-04-22 11:16:09 +08:00
data: this.zgyCount,
type: 'line'
// smooth: true,
// areaStyle: {
// color: '#e1e3eb'
// }
}
]
}
myChart.setOption(option)
2023-08-08 16:15:54 +08:00
let sizeFun = function () {
2024-04-22 11:16:09 +08:00
myChart.resize()
}
window.addEventListener('resize', sizeFun)
tootipTimer && tootipTimer.clearLoop()
tootipTimer = null
2023-08-08 16:15:54 +08:00
// 调用轮播的方法
tootipTimer = window.loopShowTooltip(myChart, option, {
interval: 2000, // 轮播间隔时间
2024-04-22 11:16:09 +08:00
loopSeries: true // 是否开启轮播循环
})
2023-08-08 16:15:54 +08:00
},
2024-04-22 11:16:09 +08:00
async getRysshyqk () {
2023-08-08 16:15:54 +08:00
try {
const res = await getRysshyqk()
2024-04-22 11:16:09 +08:00
this.data = res.data.countClass
console.log(res)
2023-08-08 16:15:54 +08:00
this.data.forEach(item => {
2024-04-22 11:16:09 +08:00
this.times.push(item.dateTime)
this.bossCount.push(item.bossCount)
this.zgyCount.push(item.zgyCount)
})
this.$nextTick(() => {
this.gr()
2023-08-08 16:15:54 +08:00
})
} catch (error) {
2024-04-22 11:16:09 +08:00
console.log('数据获取失败')
2023-08-08 16:15:54 +08:00
}
}
2024-04-22 11:16:09 +08:00
}
2023-08-08 16:15:54 +08:00
2024-04-22 11:16:09 +08:00
}
2023-08-08 16:15:54 +08:00
</script>
2024-04-22 11:16:09 +08:00
2023-08-08 16:15:54 +08:00
<style scoped lang="scss">
.container9 {
/* border: 1px solid #00ffff; */
width: 17.0833vw;
height: 21.5749vh;
.line {
width: 17.0833vw;
height: 21.5749vh;
}
}
2024-04-22 11:16:09 +08:00
</style>