Estoy tratando de agregar un título a mi gráfico que estoy creando con la biblioteca chart.js. Aquí está mi código:
<canvas id="abcdiagrammBereich" width="100" height="200"></canvas> <script type="text/javascript"> var ctx = document.getElementById('abcdiagrammBereich'); var abcdiagrammBereich = new Chart(ctx, { data: { labels: %labels%, datasets: [{ type: 'line', label: 'Dein Ergebnis', data: %ownData%, backgroundColor: ['rgba(0, 0, 0, 0)'], borderColor: ['rgba(0, 0, 0, 1)'], borderWidth: 5 }], }, options: { indexAxis: 'y', elements: { bar: {borderWidth: 1,},}, responsive: true, plugins: { legend: {position: 'top',}, titel: {display: true, text: '%titel%'}, }, scales: {x: {min: 1, max: 9}} } }); </script>Y aquí hay otra pieza de código donde quiero agregar un título:
library('ChartJS'); $value_data = array( $stanineErfolg, $staninePassung ); $label_data = array( 'subj. beruflicher Erfolg', 'berufliche Passung' ); $label_titel = 'Input'; text('Diagramm ABC Handy', array( '%titel%' => '$label_titel', '%labels%' => json_encode($label_data), '%ownData%' => json_encode($value_data) ));¿Cómo hago que el título se muestre en el gráfico?
Echando un vistazo a su código, parece que hay un error tipográfico. titel título en lugar de title .
plugins: { legend: {position: 'top',}, title: {display: true, text: '%titel%'}, // <-- title! },