<!DOCTYPE html>
<html>
<head>
<title>
Stacked Bar Chart with Subtitle Example
</title>
<script src=
"https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js">
</script>
<script src=
"https://cdn.jsdelivr.net/npm/[email protected]/dist/chart.umd.min.js">
</script>
</head>
<body>
<h1 style="color:green;">
GeeksforGeeks
</h1>
<h3 style="color:black;">
ChartJS Subtitle Configuration Example 2
</h3>
<canvas id="myChart"
width="700"
height="300">
</canvas>
<script>
var ctx =
document.getElementById('myChart').getContext('2d');
var myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: ['January',
'February',
'March',
'April',
'May'],
datasets: [
{
label: 'Dataset 1',
data: [10, 20, 15, 25, 30],
backgroundColor: 'rgba(255, 99, 132, 0.7)',
},
{
label: 'Dataset 2',
data: [20, 25, 10, 30, 15],
backgroundColor: 'rgba(54, 162, 235, 0.7)',
},
{
label: 'Dataset 3',
data: [15, 10, 20, 15, 20],
backgroundColor: 'rgba(255, 206, 86, 0.7)',
}
]
},
options: {
scales: {
x: {
stacked: true,
},
y: {
stacked: true,
beginAtZero: true,
}
},
plugins: {
title: {
display: true,
text: 'This is Title',
align: 'center',
color: 'blue',
fullSize: false,
position: 'top',
font: {
size: 18,
weight: 'bold',
family: 'Arial',
style: 'italic'
},
padding: {
top: 10,
bottom: 10,
left: 10,
right: 10
}
},
subtitle: {
display: true,
text: 'Subtitle: Monthly Data',
align: 'left',
color: 'green',
fullSize: false,
position: 'bottom',
font: {
size: 16,
weight: 'normal',
family: 'Verdana',
style: 'italic',
lineHeight: 1.5,
letterSpacing: '2px',
},
padding: {
top: 15,
bottom: 10,
left: 10,
right: 10
}
}
}
}
});
</script>
</body>
</html>