-
-
Notifications
You must be signed in to change notification settings - Fork 364
[ChartJs] Adding a better way to register Chartjs plugins #870
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ChartJs] Adding a better way to register Chartjs plugins #870
Conversation
src/Chartjs/doc/index.rst
Outdated
@@ -109,7 +109,11 @@ Then register the plugin globally. This can be done in your ``app.js`` file: | |||
import { Chart } from 'chart.js'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't you remove this line ?
src/Chartjs/doc/index.rst
Outdated
@@ -213,6 +218,26 @@ Then in your render call, add your controller as an HTML attribute: | |||
|
|||
{{ render_chart(chart, {'data-controller': 'mychart'}) }} | |||
|
|||
There is also a ``chartjs:init`` event that is called just *one* time before your | |||
first charts is rendered. That's an ideal place to `register plugins globally <Using Plugins>`_ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
first charts is rendered. That's an ideal place to `register plugins globally <Using Plugins>`_ | |
first chart is rendered. That's an ideal place to `register plugins globally <Using Plugins>`_ |
src/Chartjs/doc/index.rst
Outdated
|
||
// assets/app.js | ||
|
||
import { Chart } from 'chart.js'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This import looks useless to me, as the code snippet does not use it
Good catches - thank you Stof! |
fc28684
to
ab5f111
Compare
Sorry to post this here, but how am I able to fetch this update to my project? And thx @weaverryan for the quick fix! |
Change your version in composer.json to 2.x-dev :) |
The previous method, in npm (and likely in the native browser via importmaps) the Chart would always be imported into the Chartjs UX controller before your userland code would run to register the plugin.
Cheers!