diff --git a/docs/.vuepress/config.ts b/docs/.vuepress/config.ts index 2727f9157..395c89dba 100644 --- a/docs/.vuepress/config.ts +++ b/docs/.vuepress/config.ts @@ -134,6 +134,7 @@ export default defineConfig({ 'types/polygon' ] }, + 'developers', { title: 'Migration', collapsable: true, diff --git a/docs/guide/developers.md b/docs/guide/developers.md new file mode 100644 index 000000000..5664e7e66 --- /dev/null +++ b/docs/guide/developers.md @@ -0,0 +1,33 @@ +# Developers + +## Access to the annotation elements + +The annotation plugin uses Chart.js elements to draw the annotation requested by the user. The following APIs allows the user to get the created annotation elements to use in callbacks or for other purposes. +The APIs are available in the annotation plugin instance. + +#### Script Tag + +```html + +``` + +#### Bundlers (Webpack, Rollup, etc.) + +```javascript +// get annotation plugin instance +import annotationPlugin from 'chartjs-plugin-annotation'; +``` + +### `.getAnnotations(chart: Chart): AnnotationElement[]` + +It provides all annotation elements configured by the plugin options, even if the annotations are not visible. + +```javascript +const myLineChart = new Chart(ctx, config); +// get all annotation elements +const elements = annotationPlugin.getAnnotations(myLineChart); +``` + \ No newline at end of file diff --git a/docs/guide/integration.md b/docs/guide/integration.md index 6c6ef1f2b..012c3fcb2 100644 --- a/docs/guide/integration.md +++ b/docs/guide/integration.md @@ -10,7 +10,7 @@ title: Integration ```