Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

In Chart.js, the chart title, x-axis name, and y-axis name can be set using the options object.

To set the chart title:

var chart = new Chart(ctx, {
    type: 'bar',
    data: {...},
    options: {
        title: {
            display: true,
            text: 'Chart Title'
        },
        ...
    }
});

To set the x-axis name:

var chart = new Chart(ctx, {
    type: 'bar',
    data: {...},
    options: {
        scales: {
            xAxes: [{
                scaleLabel: {
                    display: true,
                    labelString: 'X-axis Name'
                }
            }],
            ...
        }
    }
});

To set the y-axis name:

var chart = new Chart(ctx, {
    type: 'bar',
    data: {...},
    options: {
        scales: {
            yAxes: [{
                scaleLabel: {
                    display: true,
                    labelString: 'Y-axis Name'
                }
            }],
            ...
        }
    }
});