Filling background
const config = {
type: 'doughnut',
data,
options: {
aspectRatio: 2,
plugins: {
annotation: {
annotations: {
annotation
}
}
}
}
};
const annotation = {
type: 'doughnutLabel',
content: ({chart}) => [chart.getDatasetMeta(0).total,
'pieces of fruits'
],
font: [{size: 48}, {size: 20}],
color: ['indigo', 'grey'],
backgroundColor: 'rgba(0, 0, 0, 0.1)',
borderColor: 'black',
borderWidth: 2,
borderDash: [7, 7],
spacing: 2
};
const DATA_COUNT = 6;
const MIN = 0;
const MAX = 100;
const numberCfg = {count: DATA_COUNT, min: MIN, max: MAX, decimals: 0};
const data = {
labels: ['Apples', 'Orange', 'Lime', 'Grapes', 'Apricots', 'Blackberries'],
datasets: [{
data: Utils.numbers(numberCfg)
}]
};