Customize title in Chart.js

Posted by I. B. Gd Pramana A. Putra, 26 Aug 22, last updated 26 Aug 22

Chart.js is a powerful library to let you visualize data and display them on our website. If you're looking for a code snippet to show you an example of how to customize a title in chart.js, you're in the right place.

<canvas id="myChart" width="400" height="400"></canvas>

const ctx = document.getElementById('myChart').getContext('2d');
const myChart = new Chart(ctx, {
  type: 'bar',
  data: {
    labels: ['Jan', 'Feb', 'Mar', 'Apr'],
    datasets: [{
      label: 'Months',
      data: [50, 30, 90, 70]
  options: {
        plugins: {
            title: {
                display: true,
                text: 'Title goes here ...',
                color: '#0055ff',
                position: 'bottom',
                fullSize: true,
                padding: 30,
                align: 'start',
                font: {
                	family: 'Arial',
                	size: 30,
                    weight: 'bold',
                    style: 'italic',
                    lineHeight: 2.0

I love sharing code snippets as most of the time, a quick code example is what we're looking for instead of long-written articles. If you think my code snippets are helpful and save you a lot of time, please consider buying me a cup of coffee :)

Support me via · paypal · buymeacoffee · ko-fi · trakteer
Contributed Snippets
Answer & Responses
    No comments yet

Wanna write a response?

You have to login before write a comment to this post.