add more possible colors to graphs (#819)

This commit is contained in:
Echo 2026-01-21 18:42:04 -05:00 committed by GitHub
parent 9705a34c5c
commit 585fd07859
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -201,9 +201,17 @@
window.chartInstances[elementId].destroy();
}
const ctx = canvas.getContext("2d");
const pieColors = [
'#60a5fa', '#f472b6', '#fb923c', '#facc15', '#4ade80',
'#2dd4bf', '#a78bfa', '#f87171', '#38bdf8', '#e879f9',
'#34d399', '#fbbf24', '#818cf8', '#fb7185', '#22d3ee',
'#a3e635', '#c084fc', '#f97316', '#14b8a6', '#8b5cf6',
'#ec4899', '#84cc16', '#06b6d4', '#d946ef', '#10b981'
];
const backgroundColors = labels.map((_, i) => pieColors[i % pieColors.length]);
window.chartInstances[elementId] = new Chart(ctx, {
type: "pie",
data: { labels, datasets: [{data, borderWidth: 1 }] },
data: { labels, datasets: [{data, backgroundColor: backgroundColors, borderWidth: 1 }] },
options: {
responsive: true,
maintainAspectRatio: true,