Skip to content

Conversation

@weaverryan
Copy link
Member

@weaverryan weaverryan commented May 12, 2023

Q A
Bug fix? yes
New feature? yes, but in order to fix a bug
Tickets Fix #867 Fix #754 Fix #598 Fix #167
License MIT

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!

// assets/app.js
import { Chart } from 'chart.js';
Copy link
Member

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 ?

{{ 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>`_
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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>`_

// assets/app.js
import { Chart } from 'chart.js';
Copy link
Member

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

@weaverryan
Copy link
Member Author

Good catches - thank you Stof!

@weaverryan weaverryan force-pushed the fix-chartjs-plugin-registeration branch from fc28684 to ab5f111 Compare May 15, 2023 10:42
@weaverryan weaverryan merged commit a4763d7 into symfony:2.x May 15, 2023
@Matoto951
Copy link

Sorry to post this here, but how am I able to fetch this update to my project? And thx @weaverryan for the quick fix!

@weaverryan
Copy link
Member Author

Change your version in composer.json to 2.x-dev :)

@weaverryan weaverryan deleted the fix-chartjs-plugin-registeration branch May 15, 2023 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants