|
@@ -111,11 +111,18 @@
|
|
|
</a-card>
|
|
|
</a-col>
|
|
|
</a-row>
|
|
|
+ <a-row>
|
|
|
+ <a-col :span="24">
|
|
|
+ <a-card title="">
|
|
|
+ <div id="chart-3" class="chart"></div>
|
|
|
+ </a-card>
|
|
|
+ </a-col>
|
|
|
+ </a-row>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
-import { computed, onMounted, watchEffect, unref } from 'vue'
|
|
|
+import { computed, onMounted, watch, watchEffect, unref } from 'vue'
|
|
|
import Vue3Autocounter from 'vue3-autocounter'
|
|
|
import * as echarts from 'echarts'
|
|
|
import type { ECharts } from 'echarts'
|
|
@@ -126,96 +133,287 @@ 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
|
|
|
+let roomUseVisitChart: ECharts
|
|
|
+let roomMsgChart: ECharts
|
|
|
|
|
|
-onMounted(async () => {
|
|
|
+const props = defineProps<{
|
|
|
+ current: string
|
|
|
+}>()
|
|
|
+
|
|
|
+const onelineTimeCount = computed(() => statisticStore.onlineTimeCount)
|
|
|
+const userVisitList = computed(() => statisticStore.roomUseChart.userVisitList)
|
|
|
+const userShareList = computed(() => statisticStore.roomUseChart.userShareList)
|
|
|
+
|
|
|
+const userMsgManList = computed(
|
|
|
+ () => statisticStore.roomUseChart.userMsgManList
|
|
|
+)
|
|
|
+
|
|
|
+const userMsgCountList = computed(
|
|
|
+ () => statisticStore.roomUseChart.userMsgCountList
|
|
|
+)
|
|
|
+
|
|
|
+const initTab = async () => {
|
|
|
await statisticStore.fetchTop()
|
|
|
await statisticStore.fetchOnlineTimeCount()
|
|
|
await statisticStore.fetchHeroStatus()
|
|
|
await statisticStore.fetchRoomVisitChart()
|
|
|
-
|
|
|
+}
|
|
|
+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) {
|
|
|
+ if (!onlineTimeChart) {
|
|
|
+ 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 onelineTimeCount = computed(() => statisticStore.onlineTimeCount)
|
|
|
+const initRoomVisitChart = () => {
|
|
|
+ const chart = document.getElementById('chart-2')
|
|
|
+ const ch1 = unref(userVisitList)
|
|
|
+ const ch2 = unref(userShareList)
|
|
|
+ const ch1X = ch1.map(i => i.dataKey)
|
|
|
+ const ch1Y = ch1.map(i => i.dataCount)
|
|
|
+ const ch2X = ch2.map(i => i.dataKey)
|
|
|
+ const ch2Y = ch2.map(i => i.dataCount)
|
|
|
+ const ch1Max = Math.max.apply(Math, ch1Y) + 200
|
|
|
+ const ch1Min =
|
|
|
+ Math.min.apply(Math, ch1Y) === 0 ? 0 : Math.min.apply(Math, ch1Y)
|
|
|
|
|
|
- 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
|
|
|
+ if (chart) {
|
|
|
+ if (!roomUseVisitChart) {
|
|
|
+ roomUseVisitChart = echarts.init(chart)
|
|
|
+ }
|
|
|
+ // 绘制图表
|
|
|
+ roomUseVisitChart.setOption({
|
|
|
+ tooltip: {
|
|
|
+ trigger: 'axis',
|
|
|
+ axisPointer: {
|
|
|
+ lineStyle: {
|
|
|
+ width: 1,
|
|
|
+ color: '#019680'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ legend: {
|
|
|
+ orient: 'horizontal',
|
|
|
+ bottom: 0
|
|
|
+ },
|
|
|
+ xAxis: {
|
|
|
+ type: 'category',
|
|
|
+ data: ch1X,
|
|
|
+ splitLine: {
|
|
|
+ show: true,
|
|
|
+ lineStyle: {
|
|
|
+ width: 1,
|
|
|
+ type: 'solid',
|
|
|
+ color: 'rgba(226,226,226,0.5)'
|
|
|
+ }
|
|
|
},
|
|
|
- yAxis: {
|
|
|
- min: min,
|
|
|
- max: max
|
|
|
+ axisTick: {
|
|
|
+ show: false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ yAxis: [
|
|
|
+ {
|
|
|
+ type: 'value',
|
|
|
+ max: ch2X,
|
|
|
+ splitNumber: 4,
|
|
|
+ axisTick: {
|
|
|
+ show: false
|
|
|
+ },
|
|
|
+ splitArea: {
|
|
|
+ show: true,
|
|
|
+ areaStyle: {
|
|
|
+ color: ['rgba(255,255,255,0.2)', 'rgba(226,226,226,0.2)']
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ grid: {
|
|
|
+ left: '2%',
|
|
|
+ right: '2%',
|
|
|
+ top: '2%',
|
|
|
+ bottom: '10%',
|
|
|
+ containLabel: true
|
|
|
+ },
|
|
|
+ series: [
|
|
|
+ {
|
|
|
+ smooth: true,
|
|
|
+ data: ch1Y,
|
|
|
+ type: 'line',
|
|
|
+ areaStyle: {},
|
|
|
+ name: '用户浏览量',
|
|
|
+ itemStyle: {
|
|
|
+ color: '#5ab1ef'
|
|
|
+ }
|
|
|
},
|
|
|
- series: [
|
|
|
- {
|
|
|
- name: '人数',
|
|
|
- type: 'line',
|
|
|
- smooth: true,
|
|
|
- data: yAxis
|
|
|
+ {
|
|
|
+ smooth: true,
|
|
|
+ data: ch2Y,
|
|
|
+ type: 'line',
|
|
|
+ name: '用户分享数',
|
|
|
+ areaStyle: {},
|
|
|
+ itemStyle: {
|
|
|
+ color: '#019680'
|
|
|
}
|
|
|
- ]
|
|
|
- })
|
|
|
- }
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ })
|
|
|
}
|
|
|
+}
|
|
|
|
|
|
- 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
|
|
|
+const initRoomMsgChart = () => {
|
|
|
+ const chart = document.getElementById('chart-3')
|
|
|
+ const ch1 = unref(userMsgManList)
|
|
|
+ const ch2 = unref(userMsgCountList)
|
|
|
+ const ch1X = ch1.map(i => i.dataKey)
|
|
|
+ const ch1Y = ch1.map(i => i.dataCount)
|
|
|
+ const ch2X = ch2.map(i => i.dataKey)
|
|
|
+ const ch2Y = ch2.map(i => i.dataCount)
|
|
|
+ const ch1Max = Math.max.apply(Math, ch1Y) + 200
|
|
|
+ const ch1Min =
|
|
|
+ Math.min.apply(Math, ch1Y) === 0 ? 0 : Math.min.apply(Math, ch1Y)
|
|
|
+
|
|
|
+ if (chart) {
|
|
|
+ if (!roomMsgChart) {
|
|
|
+ roomMsgChart = echarts.init(chart)
|
|
|
+ }
|
|
|
+ // 绘制图表
|
|
|
+ roomMsgChart.setOption({
|
|
|
+ tooltip: {
|
|
|
+ trigger: 'axis',
|
|
|
+ axisPointer: {
|
|
|
+ lineStyle: {
|
|
|
+ width: 1,
|
|
|
+ color: '#019680'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ legend: {
|
|
|
+ orient: 'horizontal',
|
|
|
+ bottom: 0
|
|
|
+ },
|
|
|
+ xAxis: {
|
|
|
+ type: 'category',
|
|
|
+ data: ch1X,
|
|
|
+ splitLine: {
|
|
|
+ show: true,
|
|
|
+ lineStyle: {
|
|
|
+ width: 1,
|
|
|
+ type: 'solid',
|
|
|
+ color: 'rgba(226,226,226,0.5)'
|
|
|
+ }
|
|
|
},
|
|
|
- yAxis: {
|
|
|
- min: min,
|
|
|
- max: max
|
|
|
+ axisTick: {
|
|
|
+ show: false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ yAxis: [
|
|
|
+ {
|
|
|
+ type: 'value',
|
|
|
+ max: ch2X,
|
|
|
+ splitNumber: 4,
|
|
|
+ axisTick: {
|
|
|
+ show: false
|
|
|
+ },
|
|
|
+ splitArea: {
|
|
|
+ show: true,
|
|
|
+ areaStyle: {
|
|
|
+ color: ['rgba(255,255,255,0.2)', 'rgba(226,226,226,0.2)']
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ grid: {
|
|
|
+ left: '2%',
|
|
|
+ right: '2%',
|
|
|
+ top: '2%',
|
|
|
+ bottom: '10%',
|
|
|
+ containLabel: true
|
|
|
+ },
|
|
|
+ series: [
|
|
|
+ {
|
|
|
+ smooth: true,
|
|
|
+ data: ch1Y,
|
|
|
+ type: 'bar',
|
|
|
+ areaStyle: {},
|
|
|
+ name: '用户留言数',
|
|
|
+ itemStyle: {
|
|
|
+ color: '#5ab1ef'
|
|
|
+ }
|
|
|
},
|
|
|
- series: [
|
|
|
- {
|
|
|
- name: '人数',
|
|
|
- type: 'line',
|
|
|
- smooth: true,
|
|
|
- data: yAxis
|
|
|
+ {
|
|
|
+ smooth: true,
|
|
|
+ data: ch2Y,
|
|
|
+ type: 'bar',
|
|
|
+ name: '用户留言数',
|
|
|
+ areaStyle: {},
|
|
|
+ itemStyle: {
|
|
|
+ color: '#019680'
|
|
|
}
|
|
|
- ]
|
|
|
- })
|
|
|
- }
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ })
|
|
|
}
|
|
|
+}
|
|
|
|
|
|
+watch(
|
|
|
+ () => props.current,
|
|
|
+ val => {
|
|
|
+ if (Number(val) === 1) {
|
|
|
+ initTab()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ immediate: true
|
|
|
+ }
|
|
|
+)
|
|
|
+onMounted(async () => {
|
|
|
watchEffect(() => {
|
|
|
if (unref(onelineTimeCount)?.length) {
|
|
|
initOnlineChart()
|
|
|
}
|
|
|
- if (unref(onelineTimeCount)?.length) {
|
|
|
- initOnlineChart()
|
|
|
+ if (unref(userVisitList)?.length || unref(userShareList)?.length) {
|
|
|
+ initRoomVisitChart()
|
|
|
+ }
|
|
|
+ if (unref(userMsgCountList)?.length || unref(userMsgManList)?.length) {
|
|
|
+ initRoomMsgChart()
|
|
|
}
|
|
|
})
|
|
|
|
|
|
window.onresize = function () {
|
|
|
//自适应大小
|
|
|
onlineTimeChart.resize()
|
|
|
+ roomUseVisitChart.resize()
|
|
|
}
|
|
|
})
|
|
|
</script>
|