informatica:programacion:javascript:chartjs
Tabla de Contenidos
Chart.js
Biblioteca JavaScript para crear gráficas.
Ejemplo
<div> <canvas id="myChart"></canvas> </div> <script src="https://cdn.jsdelivr.net/npm/chart.js"></script> <script> const ctx = document.getElementById('myChart'); new Chart(ctx, { type: 'bar', data: { labels: ['Red', 'Blue', 'Yellow', 'Green', 'Purple', 'Orange'], datasets: [{ label: '# of Votes', data: [12, 19, 3, 5, 2, 3], borderWidth: 1 }] }, options: { scales: { y: { beginAtZero: true } } } }); </script>
Configuración
Título gráfica
La opción title dentro de plugins permite mostrar un título en la cabecera de la gráfica.
const chart = new Chart(ctx, { type: 'line', data: data, options: { plugins: { title: { display: true, text: 'Custom Chart Title' } } } });
Título ejes de coordenadas
new Chart(ctx, { (...) options: { scales: { y: { title: { display: true, text: "Velocidad" } }, x: { title: { display: true, text: "Tiempo" } } } } });
informatica/programacion/javascript/chartjs.txt · Última modificación: por tempwin
