nuevo dash

This commit is contained in:
kvilches1410
2026-03-31 16:57:26 -03:00
parent b4a0dfae24
commit 5467427a08
9 changed files with 820 additions and 732 deletions
+47
View File
@@ -0,0 +1,47 @@
/**
* js/charts.js
* Encargado de instanciar, dibujar y destruir gráficos de Chart.js
*/
const COLORS = [
'#0052cc','#36b37e','#ff5630','#6554c0','#ff8b00',
'#00b8d9','#57d9a3','#f99cdb','#8777d9','#344563',
'#403294','#00875a','#de350b','#505f79','#42526e',
];
export const chartsManager = {
instances: {},
_peopleOrder: [],
personColor(name) {
let idx = this._peopleOrder.indexOf(name);
if (idx < 0) {
this._peopleOrder.push(name);
idx = this._peopleOrder.length - 1;
}
return COLORS[idx % COLORS.length];
},
destroyChart(id) {
if (this.instances[id]) {
this.instances[id].destroy();
delete this.instances[id];
}
},
drawBarChart(id, canvasId, labels, datasets, options = {}) {
this.destroyChart(id);
const ctx = document.getElementById(canvasId);
if (!ctx) return;
this.instances[id] = new Chart(ctx, {
type: 'bar',
data: { labels, datasets },
options: {
responsive: true,
maintainAspectRatio: false,
...options,
}
});
}
};