Skip to content

Commit

Permalink
add doc
Browse files Browse the repository at this point in the history
  • Loading branch information
stockiNail committed May 23, 2023
1 parent 6c1f360 commit b182cd6
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/.vuepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ export default defineConfig({
'types/polygon'
]
},
'developers',
{
title: 'Migration',
collapsable: true,
Expand Down
33 changes: 33 additions & 0 deletions docs/guide/developers.md
Original file line number Diff line number Diff line change
@@ -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
<script>
// get annotation plugin instance
const annotationPlugin = window['chartjs-plugin-annotation'];
</script>
```

#### 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);
```

2 changes: 1 addition & 1 deletion docs/guide/integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ title: Integration
<script src="path/to/chartjs/dist/chart.min.js"></script>
<script src="path/to/chartjs-plugin-annotation/dist/chartjs-plugin-annotation.min.js"></script>
<script>
var myChart = new Chart(ctx, {...});
const myChart = new Chart(ctx, {...});
</script>
```

Expand Down

0 comments on commit b182cd6

Please sign in to comment.