Skip to content

Commit b182cd6

Browse files
committed
add doc
1 parent 6c1f360 commit b182cd6

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

docs/.vuepress/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ export default defineConfig({
134134
'types/polygon'
135135
]
136136
},
137+
'developers',
137138
{
138139
title: 'Migration',
139140
collapsable: true,

docs/guide/developers.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Developers
2+
3+
## Access to the annotation elements
4+
5+
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.
6+
The APIs are available in the annotation plugin instance.
7+
8+
#### Script Tag
9+
10+
```html
11+
<script>
12+
// get annotation plugin instance
13+
const annotationPlugin = window['chartjs-plugin-annotation'];
14+
</script>
15+
```
16+
17+
#### Bundlers (Webpack, Rollup, etc.)
18+
19+
```javascript
20+
// get annotation plugin instance
21+
import annotationPlugin from 'chartjs-plugin-annotation';
22+
```
23+
24+
### `.getAnnotations(chart: Chart): AnnotationElement[]`
25+
26+
It provides all annotation elements configured by the plugin options, even if the annotations are not visible.
27+
28+
```javascript
29+
const myLineChart = new Chart(ctx, config);
30+
// get all annotation elements
31+
const elements = annotationPlugin.getAnnotations(myLineChart);
32+
```
33+

docs/guide/integration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ title: Integration
1010
<script src="path/to/chartjs/dist/chart.min.js"></script>
1111
<script src="path/to/chartjs-plugin-annotation/dist/chartjs-plugin-annotation.min.js"></script>
1212
<script>
13-
var myChart = new Chart(ctx, {...});
13+
const myChart = new Chart(ctx, {...});
1414
</script>
1515
```
1616

0 commit comments

Comments
 (0)