调整表格数据及折线图数据

This commit is contained in:
2026-01-23 15:35:54 +08:00
parent 2ff8fec4b0
commit 2f8bdf99ed
2 changed files with 132 additions and 23 deletions

View File

@@ -83,7 +83,7 @@ function updateChart1() {
const option = {
title: {
text: '折线图1',
text: '今日盈亏数据',
left: 'center'
},
tooltip: {
@@ -106,7 +106,7 @@ function updateChart1() {
data: chartLabels.value,
axisLabel: {
rotate: 45,
interval: 11, // 每12个标签显示一个避免重叠
interval: chartLabels.value.length > 12 ? Math.floor(chartLabels.value.length / 12) : 0, // 根据标签数量动态调整间隔,确保至少显示一些标签
fontSize: 10
}
},
@@ -163,8 +163,15 @@ async function fetchChartData() {
console.log('获取折线图数据');
const response = await axios.get('http://localhost:8080/api/charts/line1');
console.log('折线图数据响应:', response.data);
if (response.data && response.data.data) {
chartData1.value = response.data.data;
if (response.data) {
// 更新数据
if (response.data.data) {
chartData1.value = response.data.data;
}
// 更新标签
if (response.data.labels) {
chartLabels.value = response.data.labels;
}
// 确保数据长度与标签长度一致
if (chartData1.value.length !== chartLabels.value.length) {
console.warn('数据长度与标签长度不一致,使用默认数据');