[Chartjs]-How to disable the legend in chart.js

1👍

There is error in your code in brackets at y{}, that’s why its not working. Here is the updated code. Try this:-

 <script>
    const ctx = document.getElementById('myChart');
  
    new Chart(ctx, {
      type: 'bar',
      data: {
        labels: ['Listening', 'Reading', 'Writing', 'Speaking', 'Overall'],
        datasets: [{
          {% for result in regular_test_1 %}
          label: 'Band Score',
          data: [{{ result["listening"] }}, {{ result["reading"] }}, {{ result["writing"] }}, {{ result["speaking"] }}, {{ result["overall"] }}],
          {% endfor %}
          backgroundColor: [
                'rgba(255, 99, 132, 0.2)',
                'rgba(54, 162, 235, 0.2)',
                'rgba(255, 206, 86, 0.2)',
                'rgba(75, 192, 192, 0.2)',
                'rgba(153, 102, 255, 0.2)'
        ],
          borderWidth: 1
        }]
      },
      options: {
        responsive: false,
        scales: {
          y: {
            max: 9,
            min: 1,
            beginAtZero: true,
          }
        },
        plugins: {
          legend: {
            display: false
          }
        }
      }
    });
  </script>  

Leave a comment