JSFiddle - React, Tailwind, and code Playground
HTML
<canvas id="myChart" width="400" height="150"></canvas>
<script src="https://cdn.jsdelivr.net/npm/chart.js@3.7.0/dist/chart.min.js"></script>
JavaScript
const ctx = document.getElementById('myChart').getContext('2d');
const myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: ['Jan', 'Feb', 'Mar', 'Apr'],
datasets: [{
label: 'Month',
data: [10, 20, 50, 30]
}]
},
options: {
plugins: {
subtitle: {
display: true,
text: 'Title goes here ...',
color: '#ff0000',
font: {
size: 20
}
}
}
}
});