调整趋势图功能,加入了查询数据库,分析群聊聊天数量的功能
This commit is contained in:
@@ -151,7 +151,7 @@
|
||||
<div v-else>
|
||||
<div class="chart-container">
|
||||
<h3>消息数量趋势</h3>
|
||||
<canvas id="messageTrendChart" width="800" height="300"></canvas>
|
||||
<canvas ref="messageTrendChart" width="800" height="300"></canvas>
|
||||
</div>
|
||||
<div style="margin-top: 20px; text-align: center;">
|
||||
<el-radio-group v-model="trendDays" @change="loadMessageTrend">
|
||||
@@ -452,11 +452,11 @@
|
||||
|
||||
renderTrendChart(data) {
|
||||
try {
|
||||
// 获取Canvas元素
|
||||
const canvas = document.getElementById('messageTrendChart');
|
||||
// 使用Vue的ref获取Canvas元素
|
||||
const canvas = this.$refs.messageTrendChart;
|
||||
|
||||
if (!canvas) {
|
||||
console.error('找不到Canvas元素,ID: messageTrendChart');
|
||||
console.error('找不到Canvas元素,ref: messageTrendChart');
|
||||
this.$message.error('无法找到图表元素,请尝试重新打开对话框');
|
||||
this.trendLoading = false;
|
||||
return;
|
||||
@@ -475,8 +475,8 @@
|
||||
}
|
||||
|
||||
// 准备数据
|
||||
const labels = data.dates;
|
||||
const messageData = data.counts.map(count => parseInt(count) || 0);
|
||||
const labels = data.dates || [];
|
||||
const messageData = (data.counts || []).map(count => parseInt(count) || 0);
|
||||
|
||||
// 创建新图表
|
||||
this.charts.trendChart = new Chart(ctx, {
|
||||
|
||||
Reference in New Issue
Block a user