1👍
✅
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>
Source:stackexchange.com