score:1

Accepted answer

your options object is wrong, chart.js version 3 has some major breaking changes please read the migration guide for all of them: https://www.chartjs.org/docs/master/getting-started/v3-migration.html

for the title and legend they have been moved to the plugins section and the scales are no arrays anymore but just objects

example:

var options = {
  type: 'line',
  data: {
    labels: ["red", "blue", "yellow", "green", "purple", "orange"],
    datasets: [{
      label: '# of votes',
      data: [12, 19, 3, 5, 2, 3],
      borderwidth: 1
    }]
  },
  options: {
    plugins: {
      title: {
        display: true,
        text: 'title'
      },
      legend: {
        position: 'bottom'
      }
    },
    scales: {
      y: {
        ticks: {
          font: {
            size: 20
          }
        }
      },
      x: {
        ticks: {
          font: {
            size: 20
          }
        }
      }
    }
  }
}

var ctx = document.getelementbyid('chartjscontainer').getcontext('2d');
new chart(ctx, options);
<body>
  <canvas id="chartjscontainer" width="600" height="400"></canvas>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/chart.js/3.4.0/chart.js"></script>
</body>


Related Query

More Query from same tag