const annotation = {
type: 'line',
borderColor: 'lightGreen',
borderDashOffset: 0,
borderWidth: 10,
drawTime: 'beforeDatasetsDraw',
label: {
enabled: false,
backgroundColor: 'green',
borderWidth: 0,
drawTime: 'afterDatasetsDraw',
color: 'white',
content: (ctx) => ['Average of dataset', 'is: ' + average(ctx).toFixed(3)],
textAlign: 'center'
},
scaleID: 'y',
value: (ctx) => average(ctx),
enter(ctx, event) {
toggleLabel(ctx, event);
},
leave(ctx, event) {
toggleLabel(ctx, event);
}
};