|
@@ -77,7 +77,9 @@
|
|
|
<a-card title="带看次数排行(前5)" :bordered="false">
|
|
|
<ul class="topic-list">
|
|
|
<li v-for="top in takeLookList" :key="top.dataKey">
|
|
|
- <p><span>{{ top.dataKey }}</span> <span>{{ top.dataCount }}</span></p>
|
|
|
+ <p>
|
|
|
+ <span>{{ top.dataKey }}</span> <span>{{ top.dataCount }}</span>
|
|
|
+ </p>
|
|
|
</li>
|
|
|
</ul>
|
|
|
</a-card>
|
|
@@ -86,25 +88,34 @@
|
|
|
<a-card title="留言数排行(前5)" :bordered="false">
|
|
|
<ul class="topic-list">
|
|
|
<li v-for="top in danmakuList" :key="top.dataKey">
|
|
|
- <p><span>{{ top.dataKey }}</span> <span>{{ top.dataCount }}</span></p>
|
|
|
+ <p>
|
|
|
+ <span>{{ top.dataKey }}</span> <span>{{ top.dataCount }}</span>
|
|
|
+ </p>
|
|
|
</li>
|
|
|
</ul>
|
|
|
</a-card>
|
|
|
</a-col>
|
|
|
</a-row>
|
|
|
|
|
|
- <a-row>
|
|
|
+ <a-row style="margin-bottom: 20px">
|
|
|
<a-col :span="24">
|
|
|
<a-card title="各时间段在线人数">
|
|
|
<div id="chart-1" class="chart"></div>
|
|
|
</a-card>
|
|
|
</a-col>
|
|
|
</a-row>
|
|
|
+ <a-row>
|
|
|
+ <a-col :span="24">
|
|
|
+ <a-card title="房间使用情况">
|
|
|
+ <div id="chart-2" class="chart"></div>
|
|
|
+ </a-card>
|
|
|
+ </a-col>
|
|
|
+ </a-row>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
-import { computed, onMounted } from 'vue'
|
|
|
+import { computed, onMounted, watchEffect, unref } from 'vue'
|
|
|
import Vue3Autocounter from 'vue3-autocounter'
|
|
|
import * as echarts from 'echarts'
|
|
|
import type { ECharts } from 'echarts'
|
|
@@ -115,36 +126,96 @@ const statisticStore = useStatisticStore()
|
|
|
const takeLookList = computed(() => statisticStore.top5.takeLookList)
|
|
|
const danmakuList = computed(() => statisticStore.top5.danmakuList)
|
|
|
const heroStatus = computed(() => statisticStore.roomData)
|
|
|
+let onlineTimeChart: ECharts
|
|
|
+let roomUseChart: ECharts
|
|
|
|
|
|
onMounted(async () => {
|
|
|
await statisticStore.fetchTop()
|
|
|
await statisticStore.fetchOnlineTimeCount()
|
|
|
await statisticStore.fetchHeroStatus()
|
|
|
- const chart1 = document.getElementById('chart-1')
|
|
|
- let myChart: ECharts
|
|
|
- if (chart1) {
|
|
|
- myChart = echarts.init(chart1)
|
|
|
- // 绘制图表
|
|
|
- myChart.setOption({
|
|
|
- title: { text: '总用户量' },
|
|
|
- tooltip: {},
|
|
|
- xAxis: {
|
|
|
- data: ['12-3', '12-4', '12-5', '12-6', '12-7', '12-8']
|
|
|
- },
|
|
|
- yAxis: {},
|
|
|
- series: [
|
|
|
- {
|
|
|
- name: '用户量',
|
|
|
- type: 'line',
|
|
|
- data: [5, 20, 36, 10, 10, 20]
|
|
|
- }
|
|
|
- ]
|
|
|
- })
|
|
|
+ await statisticStore.fetchRoomVisitChart()
|
|
|
+
|
|
|
+
|
|
|
+ const onelineTimeCount = computed(() => statisticStore.onlineTimeCount)
|
|
|
+
|
|
|
+ const initOnlineChart = () => {
|
|
|
+ const chart1 = document.getElementById('chart-1')
|
|
|
+ const data = unref(onelineTimeCount)
|
|
|
+ const xAxis = data.map(i => i.dataKey)
|
|
|
+ const yAxis = data.map(i => i.dataCount)
|
|
|
+ const max = Math.max.apply(Math, yAxis) + 200
|
|
|
+ const min =
|
|
|
+ Math.min.apply(Math, yAxis) === 0 ? 0 : Math.min.apply(Math, yAxis)
|
|
|
+ if (chart1) {
|
|
|
+ onlineTimeChart = echarts.init(chart1)
|
|
|
+ // 绘制图表
|
|
|
+ onlineTimeChart.setOption({
|
|
|
+ title: { text: '' },
|
|
|
+ tooltip: {},
|
|
|
+ xAxis: {
|
|
|
+ data: xAxis
|
|
|
+ },
|
|
|
+ yAxis: {
|
|
|
+ min: min,
|
|
|
+ max: max
|
|
|
+ },
|
|
|
+ series: [
|
|
|
+ {
|
|
|
+ name: '人数',
|
|
|
+ type: 'line',
|
|
|
+ smooth: true,
|
|
|
+ data: yAxis
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ const initRoomUseChart = () => {
|
|
|
+ const chart1 = document.getElementById('chart-2')
|
|
|
+ const data = unref(onelineTimeCount)
|
|
|
+ const xAxis = data.map(i => i.dataKey)
|
|
|
+ const yAxis = data.map(i => i.dataCount)
|
|
|
+ const max = Math.max.apply(Math, yAxis) + 200
|
|
|
+ const min =
|
|
|
+ Math.min.apply(Math, yAxis) === 0 ? 0 : Math.min.apply(Math, yAxis)
|
|
|
+ if (chart1) {
|
|
|
+ onlineTimeChart = echarts.init(chart1)
|
|
|
+ // 绘制图表
|
|
|
+ onlineTimeChart.setOption({
|
|
|
+ title: { text: '' },
|
|
|
+ tooltip: {},
|
|
|
+ xAxis: {
|
|
|
+ data: xAxis
|
|
|
+ },
|
|
|
+ yAxis: {
|
|
|
+ min: min,
|
|
|
+ max: max
|
|
|
+ },
|
|
|
+ series: [
|
|
|
+ {
|
|
|
+ name: '人数',
|
|
|
+ type: 'line',
|
|
|
+ smooth: true,
|
|
|
+ data: yAxis
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+ watchEffect(() => {
|
|
|
+ if (unref(onelineTimeCount)?.length) {
|
|
|
+ initOnlineChart()
|
|
|
+ }
|
|
|
+ if (unref(onelineTimeCount)?.length) {
|
|
|
+ initOnlineChart()
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
window.onresize = function () {
|
|
|
//自适应大小
|
|
|
- myChart.resize()
|
|
|
+ onlineTimeChart.resize()
|
|
|
}
|
|
|
})
|
|
|
</script>
|