# 1.x Migration Guide
chartjs-plugin-annotation plugin version 1 introduces a number of breaking changes in order to compatible with Chart.js 3 and to align with Chart.js 3 options.
# Setup and installation
Chart.js 3 is tree-shakeable and thus requires registering the plugins when used as an npm module. Here is an example:
import { Chart, LineController, LineElement, PointElement, LinearScale } from 'chart.js';
import Annotation from 'chartjs-plugin-annotation';
Chart.register(LineController, LineElement, PointElement, LinearScale, Annotation);
const Chart = new Chart(ctx, {
type: 'line',
// data: ...
options: {
plugins: {
annotation: {
// annotation plugin options
annotations: [{
// annotation element options
type: 'line',
scaleID: 'y',
value: 25,
borderColor: 'red',
borderWidth: 2
}]
}
}
}
}):
# Options
# Plugin options
eventsarray was removed. Listened events are determined automatically from the hooks specified.enter,leave,click,dblclickevent hooks can now be defined also at plugin level options.
# Element options
onMouseenterwas removed. Useenterinstead.onMouseleavewas removed. Useleaveinstead.onMouseoverwas removed. Useenterinstead.onMouseoutwas removed. Useleaveinstead.onMousemovewas removed.onMousedownwas removed. Useclickinstead.onMouseupwas removed. Useclickinstead.onClickwas removed. Useclickinstead.onDblclickwas removed. Usedblclickinstead.onContextmenuwas removed.onWheelwas removed.
# Line
modewas removed. The mode is automatically calculated based on the scale.positionvalues were changed to'start','center'and'end'.'start'replaces previous'left'and'top'.'end'replaces previous'right'and'bottom'.
# Label
fontColorwas renamed tofont.colorfontFamilywas renamed tofont.familyfontSizewas renamed tofont.sizefontStylewas renamed tofont.stylelineHeightwas renamed tofont.lineHeight
# Event hooks
- Event hooks are now supplied with single
contextparameter, containingchartandelementproperties.chartis the chart instance andelementis the event target annotation element. - Events are now fired from
beforeEventhook.