//1、安装脚手架
npm install --save echarts vue-echarts
//2、创建图表
<template>
<div>
<div ref="chart" style="width: 400px; height: 400px;"></div>
</div>
</template>
<script>
import ECharts from 'vue-echarts';
export default {
components: {
'v-chart': ECharts
},
mounted() {
this.drawChart();
},
methods: {
drawChart() {
// 使用ECharts库绘制图表
let chart = this.$refs.chart.$chart;
// 根据数据库中的数据绘制统计图表
// 此处省略统计图表绘制的具体代码,可以根据需求选择合适的图表类型和样式
// 示例:绘制一个柱状图
chart.setOption({
xAxis: {
type: 'category',
data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
},
yAxis: {
type: 'value'
},
series: [{
type: 'bar',
data: [220, 230, 250, 180, 170, 210, 256]
}]
});
}
}
};
</script>