Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

294
Visualizações
How do I add a title to a chart from chart.js?

I am trying to add a title to my chart which I am creating with the chart.js library. Here is my code:

<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>

And here is another piece of code where I want to add a title:

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)
));

How do I make the title display in the chart?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Having a look to your code, it seems there is a typo. You wrote titel instead of title.

plugins: {
               legend: {position: 'top',},
               title: {display: true, text: '%titel%'}, // <-- title!
              },
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda