diff --git a/app/static/laboratorio.js b/app/static/laboratorio.js index b9a105a..661db72 100644 --- a/app/static/laboratorio.js +++ b/app/static/laboratorio.js @@ -83,16 +83,20 @@ ); } + // Solo lo visual sale de tokens de app.css (--grafica-*, --fuente*): barras con esquinas + // superiores de 4 px, rejilla tenue, ejes en mono y leyenda arriba al centro. function dibujar(vigente, simulada) { const lienzo = $("#lab-grafica"); if (!window.Chart || !lienzo) return; const estilo = getComputedStyle(document.documentElement); - const color = (variable) => estilo.getPropertyValue(variable).trim(); + const token = (variable) => estilo.getPropertyValue(variable).trim(); + const ejes = { color: token("--grafica-ejes"), font: { family: token("--fuente-mono"), size: 10.5 } }; + const barra = { borderRadius: 4, maxBarThickness: 44, categoryPercentage: 0.7, barPercentage: 0.9 }; const datos = { labels: ["Bajo", "Medio", "Alto"], datasets: [ - { label: `Vigente (${modelo.version})`, data: NIVELES.map((n) => vigente[n]), backgroundColor: color("--tono-neutro") }, - { label: "Simulada", data: simulada ? NIVELES.map((n) => simulada[n]) : [], backgroundColor: color("--tono-acento") }, + { ...barra, label: `Vigente (${modelo.version})`, data: NIVELES.map((n) => vigente[n]), backgroundColor: token("--grafica-vigente") }, + { ...barra, label: "Simulada", data: simulada ? NIVELES.map((n) => simulada[n]) : [], backgroundColor: token("--grafica-simulada") }, ], }; if (grafica) { @@ -102,7 +106,21 @@ grafica = new window.Chart(lienzo, { type: "bar", data: datos, - options: { animation: false, scales: { y: { beginAtZero: true, ticks: { precision: 0 } } } }, + options: { + animation: false, + maintainAspectRatio: false, + plugins: { + legend: { + position: "top", + align: "center", + labels: { boxWidth: 10, boxHeight: 10, padding: 16, color: token("--color-texto-suave"), font: { family: token("--fuente"), size: 12.5 } }, + }, + }, + scales: { + x: { grid: { display: false }, border: { color: token("--grafica-rejilla") }, ticks: ejes }, + y: { beginAtZero: true, grid: { color: token("--grafica-rejilla") }, border: { display: false }, ticks: { ...ejes, precision: 0 } }, + }, + }, }); } }