tercer commit

This commit is contained in:
kvilches1410
2026-04-01 11:34:43 -03:00
parent 7410b22623
commit a2d49b441e
6 changed files with 400 additions and 26 deletions
+38 -1
View File
@@ -43,5 +43,42 @@ export const chartsManager = {
...options,
}
});
}
},
drawDoughnutChart(id, canvasId, labels, data, backgroundColors, options = {}) {
this.destroyChart(id);
const ctx = document.getElementById(canvasId);
if (!ctx) return;
this.instances[id] = new Chart(ctx, {
type: 'doughnut',
data: {
labels,
datasets: [{ data, backgroundColor: backgroundColors, borderWidth: 2, borderColor: '#fff' }],
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: { legend: { position: 'bottom', labels: { font: { size: 11 } } } },
...options,
}
});
},
drawLineChart(id, canvasId, labels, datasets, options = {}) {
this.destroyChart(id);
const ctx = document.getElementById(canvasId);
if (!ctx) return;
this.instances[id] = new Chart(ctx, {
type: 'line',
data: { labels, datasets },
options: {
responsive: true,
maintainAspectRatio: false,
tension: 0.4,
...options,
}
});
},
};