Fix chart

This commit is contained in:
Jeffrey Serio 2024-11-21 11:38:20 -06:00
parent b895ca5794
commit 28c7e49200

45
main.go
View File

@ -955,6 +955,7 @@ func getTemplateContent(name string) string {
async function createChart() { async function createChart() {
const data = await fetchData(); const data = await fetchData();
const ctx = document.getElementById('seederStatsChart').getContext('2d'); const ctx = document.getElementById('seederStatsChart').getContext('2d');
Chart.defaults.color = "#fff";
new Chart(ctx, { new Chart(ctx, {
type: 'line', type: 'line',
@ -964,24 +965,24 @@ func getTemplateContent(name string) string {
{ {
label: '<4 seeders', label: '<4 seeders',
data: data.map((d) => d.lowSeedersTB), data: data.map((d) => d.lowSeedersTB),
backgroundColor: 'rgba(255, 99, 132, 0.7)', backgroundColor: '#f5c2e7',
borderColor: 'rgba(255, 99, 132, 1)', borderColor: '#f5c2e7',
fill: true, fill: true,
order: 3 order: 3
}, },
{ {
label: '4-10 seeders', label: '4-10 seeders',
data: data.map((d) => d.mediumSeedersTB), data: data.map((d) => d.mediumSeedersTB),
backgroundColor: 'rgba(255, 206, 86, 0.7)', backgroundColor: '#f9e2af',
borderColor: 'rgba(255, 206, 86, 1)', borderColor: '#f9e2af',
fill: true, fill: true,
order: 2 order: 2
}, },
{ {
label: '>10 seeders', label: '>10 seeders',
data: data.map((d) => d.highSeedersTB), data: data.map((d) => d.highSeedersTB),
backgroundColor: 'rgba(75, 192, 192, 0.7)', backgroundColor: '#74c7ec',
borderColor: 'rgba(75, 192, 192, 1)', borderColor: '#74c7ec',
fill: true, fill: true,
order: 1 order: 1
} }
@ -994,43 +995,47 @@ func getTemplateContent(name string) string {
type: 'category', type: 'category',
title: { title: {
display: true, display: true,
text: 'Date' text: 'Date',
} },
}, },
y: { y: {
stacked: true, stacked: true,
title: { title: {
display: true, display: true,
text: 'Terabytes' text: 'Terabytes',
}, },
ticks: { ticks: {
callback: function(value) { callback: function(value) {
return value + 'TB'; return value + 'TB'
} },
} },
} },
}, },
plugins: { plugins: {
title: { title: {
display: true, display: true,
text: 'Daily Seeder Stats' text: 'Daily Seeder Stats'
font: {
size: 30,
family: 'JetBrains Mono, monospace'
}
}, },
legend: { legend: {
display: true, display: true,
position: 'top' position: 'top',
}, },
tooltip: { tooltip: {
mode: 'index', mode: 'index',
intersect: false intersect: false,
} },
}, },
interaction: { interaction: {
mode: 'nearest', mode: 'nearest',
axis: 'x', axis: 'x',
intersect: false intersect: false,
} },
} },
}); })
} }
createChart(); createChart();