File size: 1,186 Bytes
77b0e0f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
<script setup lang="ts">
import { ref, onMounted } from 'vue'
import * as echarts from 'echarts'
// 创建一个引用来存储图表的 DOM 容器
const chartRef = ref(null)
const props = defineProps({
knowledgeBasesNum: {
type: Number,
default: 0
},
digitalHumanNum: {
type: Number,
default: 0
},
LiveRoomNum: {
type: Number,
default: 0
}
})
// 初始化图表的函数
const initChart = () => {
const chart = echarts.init(chartRef.value)
// 配置图表的选项
const option = {
title: {
text: '系统配置'
},
tooltip: {},
xAxis: {
data: ['知识库数量', '数字人数量', '直播间数量']
},
yAxis: {},
series: [
{
name: '数量',
type: 'bar',
data: [props.knowledgeBasesNum, props.digitalHumanNum, props.LiveRoomNum]
}
]
}
// 使用设置的配置项渲染图表
chart.setOption(option)
}
// 在组件挂载后初始化图表
onMounted(() => {
initChart()
})
</script>
<template>
<div ref="chartRef" style="width: auto; height: 400px"></div>
</template>
<style scoped>
/* 可以根据需要调整图表容器的样式 */
</style>
|