fix: 优化中控台首页的今日小时趋势
This commit is contained in:
parent
6e478efaab
commit
577571cf9f
@ -133,3 +133,11 @@ export const getIdCardVisitHistory = (data) => {
|
||||
isEncrypt: false
|
||||
})
|
||||
}
|
||||
|
||||
// 获取当天小时来访趋势
|
||||
export const getVisitHourTrend = () => {
|
||||
return request({
|
||||
method: 'get',
|
||||
url: '/visiting/visit/stat_hour',
|
||||
})
|
||||
}
|
@ -9,16 +9,11 @@
|
||||
<script setup>
|
||||
import Vechart from 'vue-echarts'
|
||||
import * as echarts from 'echarts/core';
|
||||
import {
|
||||
TitleComponent,
|
||||
ToolboxComponent,
|
||||
TooltipComponent,
|
||||
GridComponent,
|
||||
LegendComponent
|
||||
} from 'echarts/components';
|
||||
import { LineChart } from 'echarts/charts';
|
||||
import { UniversalTransition } from 'echarts/features';
|
||||
import { CanvasRenderer } from 'echarts/renderers';
|
||||
import {GridComponent, LegendComponent, TitleComponent, ToolboxComponent, TooltipComponent} from 'echarts/components';
|
||||
import {LineChart} from 'echarts/charts';
|
||||
import {UniversalTransition} from 'echarts/features';
|
||||
import {CanvasRenderer} from 'echarts/renderers';
|
||||
import {getVisitHourTrend} from '@/api/RegistVisitApi/RegistVisitApi.js';
|
||||
|
||||
|
||||
defineOptions({
|
||||
@ -37,9 +32,26 @@ echarts.use([
|
||||
]);
|
||||
|
||||
|
||||
const times = Array.from({length: 24}, (_, i) => `${i}:00`)
|
||||
const data = Array.from({length: 24}, (_, i) => Math.floor(Math.random() * 100))
|
||||
const options = {
|
||||
const options = ref({})
|
||||
|
||||
onMounted(() => {
|
||||
getData()
|
||||
})
|
||||
|
||||
const getData = async () => {
|
||||
const res = await getVisitHourTrend()
|
||||
const data = res.data.map(item => {
|
||||
return {
|
||||
...item,
|
||||
name: item.hour,
|
||||
value: item.count
|
||||
}
|
||||
})
|
||||
setChartOptions(data)
|
||||
}
|
||||
|
||||
const setChartOptions = (data) => {
|
||||
options.value = {
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
axisPointer: {
|
||||
@ -70,7 +82,7 @@ const options = {
|
||||
},
|
||||
series: [
|
||||
{
|
||||
name: 'Line 1',
|
||||
name: '今日来访',
|
||||
type: 'line',
|
||||
stack: 'Total',
|
||||
smooth: true,
|
||||
@ -104,6 +116,7 @@ const options = {
|
||||
// }
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user