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