<!DOCTYPE html>
<html>
<head>
<title>Chart.js with Paddings</title>
<script src=
"https://cdn.jsdelivr.net/npm/chart.js@latest/dist/chart.min.js">
</script>
<script src=
"https://cdn.jsdelivr.net/npm/chart.js">
</script>
<style>
body {
text-align: center;
}
.chart {
width: 80%;
margin: auto;
}
</style>
</head>
<body>
<h2>Chart.js General Padding</h2>
<div class="chart">
<canvas id="myTooltip"></canvas>
</div>
<script>
const chart = document.getElementById("myTooltip");
new Chart(chart, {
type: "bar",
data: {
labels: ["Jan", "Feb", "Mar", "Apr", "May"],
datasets: [
{
label: "Sales",
data: [35, 22, 48, 12, 45],
// Width of the line border
borderWidth: 2,
// Color of the line border
borderColor: "green",
},
],
},
options: {
layout: {
padding: {
left: 60,
right: 50,
top: 90,
bottom: 80,
},
},
plugins: {
tooltip: {
enabled: true,
},
},
},
});
</script>
</body>
</html>