[Chartjs]-Chart.js V2 formatting / styling labels

2👍

You can configure the legend using the config options section, as explained here:
http://www.chartjs.org/docs/latest/configuration/legend.html

Example:

var chartInstance = new Chart(ctx, {
    type: 'pie',
    data: data,
    options: {
        legend: {
            position: 'left',
            labels: {
                boxWidth: 15,
                padding: 20
            }
        }
    }
})

This code will move the legend to the left side of the chart, will make the colored boxes smaller, and will increase the amount of whitespace between the legend items.

Working JSFiddle: https://jsfiddle.net/o81qqrLn/1/

You can view a full list of configurable legend and label options is the documentation linked above.

Leave a comment