-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add getAnnotations function to plugin and remove _getState private one (
#892) * add getAnnotation function * add function for coverage just for interaction * add test case on getannotations * add doc
- Loading branch information
1 parent
87de801
commit 456e46b
Showing
18 changed files
with
151 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,3 +32,5 @@ const chart = new Chart('id', { | |
}, | ||
plugins: [Annotation] | ||
}); | ||
|
||
const elements = Annotation.getAnnotations(chart); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.