Add documentation on how plugin hooks interact with the chart (#8634)

* Add documentation on how plugin hooks interact with the chart

* Add draw.io file for flowcharts
This commit is contained in:
Evert Timberg 2021-03-14 01:12:06 -05:00 committed by GitHub
parent d84db2cefc
commit 1a2cc27f3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 0 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,7 @@
---
title: Plugins
---
import useBaseUrl from '@docusaurus/useBaseUrl';
Plugins are the most efficient way to customize or change the default behavior of a chart. They have been introduced at [version 2.1.0](https://github.com/chartjs/Chart.js/releases/tag/2.1.0) (global plugins only) and extended at [version 2.5.0](https://github.com/chartjs/Chart.js/releases/tag/v2.5.0) (per chart plugins and options).
@ -119,3 +120,21 @@ var chart = new Chart(ctx, {
## Plugin Core API
Read more about the [existing plugin extension hooks](https://github.com/chartjs/Chart.js/blob/master/types/index.esm.d.ts#L733).
### Chart Initialization
Plugins are notified during the initialization process. These hooks can be used to setup data needed for the plugin to operate.
<img alt="Chart.js init flowchart" src={useBaseUrl('img/init_flowchart.png')} />
### Chart Update
Plugins are notified during throughout the update process.
<img alt="Chart.js update flowchart" src={useBaseUrl('img/update_flowchart.png')} />
### Rendering
Plugins can interact with the chart throughout the render process. The rendering process is documented in the flowchart below. Each of the green processes is a plugin notification. The red lines indicate how cancelling part of the render process can occur when a plugin returns `false` from a hook. Not all hooks are cancelable, however, in general most `before*` hooks can be cancelled.
<img alt="Chart.js render pipeline flowchart" src={useBaseUrl('img/render_flowchart.png')} />

BIN
docs/static/img/init_flowchart.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
docs/static/img/render_flowchart.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

BIN
docs/static/img/update_flowchart.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB