# 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
events
array was removed. Listened events are determined automatically from the hooks specified.enter
,leave
,click
,dblclick
event hooks can now be defined also at plugin level options.
# Element options
onMouseenter
was removed. Useenter
instead.onMouseleave
was removed. Useleave
instead.onMouseover
was removed. Useenter
instead.onMouseout
was removed. Useleave
instead.onMousemove
was removed.onMousedown
was removed. Useclick
instead.onMouseup
was removed. Useclick
instead.onClick
was removed. Useclick
instead.onDblclick
was removed. Usedblclick
instead.onContextmenu
was removed.onWheel
was removed.
# Line
mode
was removed. The mode is automatically calculated based on the scale.position
values were changed to'start'
,'center'
and'end'
.'start'
replaces previous'left'
and'top'
.'end'
replaces previous'right'
and'bottom'
.
# Label
fontColor
was renamed tofont.color
fontFamily
was renamed tofont.family
fontSize
was renamed tofont.size
fontStyle
was renamed tofont.style
lineHeight
was renamed tofont.lineHeight
# Event hooks
- Event hooks are now supplied with single
context
parameter, containingchart
andelement
properties.chart
is the chart instance andelement
is the event target annotation element. - Events are now fired from
beforeEvent
hook.