Skip to content
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 add this to chart.js #131

Open
ghost opened this issue Aug 14, 2020 · 1 comment
Open

how to add this to chart.js #131

ghost opened this issue Aug 14, 2020 · 1 comment

Comments

@ghost
Copy link

ghost commented Aug 14, 2020

i am new to this. and i need more details about how to use it. help

@got2ski
Copy link

got2ski commented Sep 9, 2020

This worked for me.
In config.json have externals point to recent libraries in node_modules. Set a global dependency for chartjs-plugin-labels on chart.js with a shared global name. The charts.js has to load first before the chartjs-plugin-labels.js as stated in earlier issues. Read these, they helped me,
#47
#79

"externals": {
"sp-client-custom-fields": "node_modules/sp-client-custom-fields/dist/sp-client-custom-fields.bundle.js",
"jquery": {
"path": "node_modules/jquery/dist/jquery.min.js",
"globalName": "jQuery"
},
"chartjs": {
"path": "node_modules/chart.js/dist/Chart.min.js",
"globalName": "Chart"
},
"chartlabelsjs": {
"path": "node_modules/chartjs-plugin-labels/src/chartjs-plugin-labels.js",
"globalName": "Chart",
"globalDependencies": ["chartjs"]
}
},

Add a require for chartjs-plugin-labels with chart.js just under the imports of the TS file.

var Chart: any = require('chartjs');
require('chartlabelsjs');

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant