Reputation: 157
I use Chart.js(new version) as :
<script src="~/Plugin/Chart.js/src/chart.js"></script>
But when i demo in chrome, i get a error :
chart.js:4 Uncaught ReferenceError: require is not defined
Upvotes: 12
Views: 30377
Reputation: 846
For the Angular CLI users -> No need to add this script in angular-cli.json file, because angular-cli should pack ng2-charts lib(and other from node_modules) and add it automatically to your index.html.
https://github.com/valor-software/ng2-charts/issues/832
Upvotes: 4
Reputation: 1460
Use Chart.bundle.min.js bundle found on this page: https://cdnjs.com/libraries/Chart.js
https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.4.0/Chart.bundle.min.js
Upvotes: 6
Reputation: 347
First include the require.js
file then use RequireJS. You can download here.
Upvotes: 0
Reputation: 1257
I had the same problem after installing with Bower.
The solution as proposed in https://github.com/jtblin/angular-chart.js/issues/466 was to get specific versions of chart.js and angular-chart.js (tested with angular 1.4.0)
If you use Bower, try this in your bower.json
"chart.js": "npm:chart.js#2.1.0",
"angular-chart.js": "1.0.1"
and then run: bower install
If npm:chart.js is not working for you, you need to use a resolver.
1- Add to your .bowerrc:
{
"resolvers": [
"bower-npm-resolver"
]
}
2- Install bower-npm-resolver
npm install -g bower-npm-resolver
3- Now run bower install
again
Upvotes: 0
Reputation: 2308
in your code, pull the bundle instead. E.g ~/Plugin/Chart.js/dist/Chart.bundle.js
Upvotes: 46