fix reports

This commit is contained in:
lumijiez
2025-05-21 22:11:41 +03:00
parent 059a867493
commit 9b9d3fc821
2 changed files with 60 additions and 3 deletions

View File

@@ -89,7 +89,17 @@ function calculateStatistics(data) {
} }
async function generateCharts(data) { async function generateCharts(data) {
const timestamps = data.map(item => new Date(item.timestamp.$date || item.timestamp).toLocaleTimeString()) // Format timestamps to be less cluttered
const timestamps = data.map((item, index) => {
// Only show every nth label to reduce clutter
if (index % Math.ceil(data.length / 6) !== 0) return ''
const date = new Date(item.timestamp.$date || item.timestamp)
return date.toLocaleTimeString('en-US', {
hour: 'numeric',
minute: '2-digit',
hour12: true
})
})
// Battery Capacity Chart // Battery Capacity Chart
const batteryCapacityChart = new QuickChart() const batteryCapacityChart = new QuickChart()
@@ -117,9 +127,22 @@ async function generateCharts(data) {
} }
}, },
scales: { scales: {
x: {
ticks: {
maxRotation: 0,
font: { size: 10 },
padding: 10
},
grid: {
display: false
}
},
y: { y: {
beginAtZero: true, beginAtZero: true,
max: 100 max: 100,
grid: {
color: 'rgba(0, 0, 0, 0.1)'
}
} }
} }
} }
@@ -159,6 +182,23 @@ async function generateCharts(data) {
text: 'Power Generation and Consumption', text: 'Power Generation and Consumption',
font: { size: 16 } font: { size: 16 }
} }
},
scales: {
x: {
ticks: {
maxRotation: 0,
font: { size: 10 },
padding: 10
},
grid: {
display: false
}
},
y: {
grid: {
color: 'rgba(0, 0, 0, 0.1)'
}
}
} }
} }
}) })
@@ -187,6 +227,23 @@ async function generateCharts(data) {
text: 'Inverter Temperature Over Time', text: 'Inverter Temperature Over Time',
font: { size: 16 } font: { size: 16 }
} }
},
scales: {
x: {
ticks: {
maxRotation: 0,
font: { size: 10 },
padding: 10
},
grid: {
display: false
}
},
y: {
grid: {
color: 'rgba(0, 0, 0, 0.1)'
}
}
} }
} }
}) })
@@ -277,7 +334,7 @@ async function generatePDF(stats, timeRange, data) {
} }
// Page 1: Overview and Battery Statistics // Page 1: Overview and Battery Statistics
drawHeader(page1, 'UTM Solar Panel Report') drawHeader(page1, 'Solar Panel Report')
// Draw battery capacity chart // Draw battery capacity chart
const charts = await generateCharts(data) const charts = await generateCharts(data)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 15 KiB