OutLabels Plugin

var data = {
	type: 'pie',
	data: {
		labels: ["Red",
		"Green",
		"Yellow"],
	datasets: [{
		data: [300, 50, 100],
		backgroundColor: [
                      "#F7464A",
		      "#46BFBD",
		      "#FDB45C"],
		hoverBackgroundColor: [
                      "#FF5A5E",
		      "#5AD3D1",
		      "#FFC870"]
		}]
	}
}

var options = {
	responsive: true,
	maintainAspectRatio: false,
	layout: {
		padding: 10
	},
	plugins: {
		legend: {
			display: false
		},
		outlabels: {
			text: "%l (%p)",
			textAlign: "center",
			font: {
				resizable: true,
				minSize: 18,
				maxSize: 25
			}
		}
	}
}

//Initialize the chart by using setData
elements.chart.setData(data);
//Initialize additional options for outlabels plugin
elements.chart.setOptions(options);

Options

props

Text Options

Label's content can be controlled by changing the text option's value. Labels can be displayed on multiple lines by using the newline character (\n) between each line.

The space between each line can be adjusted using the font.lineHeight option.

Following scopes will be replaced automatically:

label

*Note that this plugin will not work when used along side data labels plugin (Use one or the other)

Last updated

Was this helpful?