-
Notifications
You must be signed in to change notification settings - Fork 215
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
How to make plugin not be global? #121
Comments
Have the same issue, thanks for workaround |
Having a similar issue. I am unable to disable the plugin on other charts on the page with plugins: false. I have also tried: |
I had the same problem. If you look at the source code in chartjs-plugin-labels.js, the plugin is registered as global: Chart.plugins.register(/* plugin object */); I copied the file and modified the source code to return the plugin rather than registering it globally. Then when creating the chart, I passed in the plugin. See more about passing a plugin directly to a chart here: https://www.chartjs.org/docs/2.9.4/developers/plugins.html. Attached the updated code to just return and export the plugin object rather than globally registering it: |
I fixed my issue.
ChartDataLabels plugin was registered globally in another chart that I had. instead I register locally and that fixed my issue. Docs basically I just had to remove this line in all my chart definitions
instead I just need it the ChartDataLabels in my plugins object:
|
I have many chart in any type in my application and I'm using chartjs-plugin-labels to write label on pie chartjs but that affect other charts, I can use of
plugins: {labels: false}
and its work but I need to a way that to make plugin private just to specific charts.I'm using of this in angular8
import * as Chart from 'chart.js';
import 'chartjs-plugin-labels';
How can I do it?
thanks
The text was updated successfully, but these errors were encountered: