Ng2-charts: Support in Angular 6

Created on 19 Jun 2018  路  11Comments  路  Source: valor-software/ng2-charts

is it supported in Angular 6?

Most helpful comment

Yes it does, I just made it work, without any particular operation

All 11 comments

I would really like to know, does it?

Yes it does, I just made it work, without any particular operation

Asking the real questions. I wish this was by default on all angular libraries.

Yes it does, I have just created a new project with Angular 6 version, there is my package.json dependencies.

"dependencies": {
    "@angular/animations": "^6.0.2",
    "@angular/common": "^6.0.2",
    "@angular/compiler": "^6.0.2",
    "@angular/core": "^6.0.2",
    "@angular/forms": "^6.0.2",
    "@angular/http": "^6.0.2",
    "@angular/platform-browser": "^6.0.2",
    "@angular/platform-browser-dynamic": "^6.0.2",
    "@angular/router": "^6.0.2",
    "core-js": "^2.5.4",
    "ng2-charts": "^1.6.0",
    "rxjs": "^6.0.0",
    "zone.js": "^0.8.26"
  }

Just verify the documentation to implements library correctly.

I'm new to angular 6, do you guys know how to properly include the chart.js lib such that it works in production too?

That wasn't what i was asking.

it works on angular 6 but I'm not sure it will on angular 7:

just got the following errors:

Package "ng2-charts" has an incompatible peer dependency to "@angular/common" (requires "^2.3.0 || >=4.0.0" (extended), would install "7.0.0-rc.0"). Package "ng2-charts" has an incompatible peer dependency to "@angular/core" (requires "^2.3.0 || >=4.0.0" (extended), would install "7.0.0-rc.0"). Incompatible peer dependencies found. See above.

@Gullfaxi171 The error is thrown because the ng2-charts require a stable package. Note that the installed version of Angular is 7.0.0-rc.0. It should work with 7.0.0 (stable channel)

For Angular 7.1, this worked for me, add the path to chartjs node_module script to the scripts array in the angular.json and import the ChartsModule normally.

"assets": [ "src/favicon.ico", "src/assets" ], "styles": [ "src/styles.css", "node_modules/bootstrap/dist/css/bootstrap.min.css" ], "scripts": [ "node_modules/chart.js/dist/Chart.min.js" ]

This project is now fully updated for Angular 7 with some new enhancements such as type safety.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shenriksen4 picture shenriksen4  路  3Comments

sarn3792 picture sarn3792  路  4Comments

shyamal890 picture shyamal890  路  4Comments

dslima90 picture dslima90  路  3Comments

RKornu picture RKornu  路  3Comments