Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

293
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!