Using canvas as labels
const config = {
type: 'line',
data,
options: {
scales: {
y: {
beginAtZero: true,
}
},
plugins: {
annotation: {
annotations: {
annotation1,
annotation2
}
}
}
}
};
const annotation1 = {
type: 'box',
backgroundColor: 'rgba(165, 214, 167, 0.2)',
borderWidth: 0,
xMax: 2,
xMin: 5,
label: {
display: true,
content: Utils.getSpiral(),
position: {
x: 'center',
y: 'start'
}
}
};
const annotation2 = {
type: 'box',
backgroundColor: 'rgba(188, 170, 164, 0.2)',
borderWidth: 0,
xMax: 6,
xMin: 10,
label: {
display: true,
content: Utils.getHouse(),
position: {
x: 'center',
y: 'end'
}
}
};
const DATA_COUNT = 12;
const MIN = 10;
const MAX = 100;
const numberCfg = {count: DATA_COUNT, min: MIN, max: MAX};
const data = {
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
datasets: [{
data: Utils.numbers(numberCfg)
}]
};