93Alliance / ng-chartjs

A fully functional Angular2+ chart.js library.
https://93alliance.github.io/ng-chartjs/
MIT License
87 stars 10 forks source link

Cannot use namespace 'Chart' as a type error #29

Closed patolax closed 1 year ago

patolax commented 3 years ago

I moved my project to angular 11. Then upgraded the modules to following versions.

"chart.js": "2.9.4",
"chartjs-plugin-annotation": "0.5.7",
"ng-chartjs": "0.2.1"
"@types/chart.js": "2.9.31",

I end up getting this error. I also tried using all most recent versions of each modules but error does not go away. How can we move Forward.

node_modules/ng-chartjs/node_modules/chart.js/types/index.esm"' has no exported member 'ChartDataSets'.

18     datasets: Chart.ChartDataSets[];
                       ~~~~~~~~~~~~~

Error: node_modules/ng-chartjs/lib/ng-chartjs.directive.d.ts:37:12 - error TS2709: Cannot use namespace 'Chart' as a type.

37     chart: Chart;
              ~~~~~

If I use old versions we use in angular 7 after upgrading to angular 11, we get following error "ng-chartjs": "0.0.9", "chart.js": "2.9.3", "@types/chart.js": "2.7.42",

R3InjectorError(DashboardModule)[NgChartjsService -> InjectionToken [ngx-chart-js] Global Custom Plugin -> InjectionToken [ngx-chart-js] Global Custom Plugin -> InjectionToken [ngx-chart-js] Global Custom Plugin -> InjectionToken [ngx-chart-js] Global Custom Plugin]: NullInjectorError: No provider for InjectionToken [ngx-chart-js] Global Custom Plugin!

93Alliance commented 3 years ago

Later I will update ng-chartjs to Angular 11.

duongleh commented 3 years ago

@93Alliance please upgrade to Angular 11 as soon as possible. I really need it in my project.

93Alliance commented 3 years ago

The ng-chartjs has been updated to Angular 11!

duongleh commented 3 years ago

@93Alliance the issues still persists

93Alliance commented 3 years ago

"chart.js": "2.9.4", "chartjs-plugin-annotation": "0.5.7", "ng-chartjs": "0.2.2" "@types/chart.js": "2.9.31",

What is error?

93Alliance commented 3 years ago

You can look at the ng-chartjs repository code.

duongleh commented 3 years ago

image image @93Alliance the problem is the same as in the original description

93Alliance commented 3 years ago

ngx-lite-chartjs.tar.gz

Please try this project. I'm ok!

ganesh-vellanki commented 3 years ago

Hi @93Alliance I am able to install latest 0.2.2 & run existing project without any issues, thanks for the update! I have a question though, Are you planning on releasing new version to support chartjs 3.. ?

ganesh-vellanki commented 3 years ago

Hi @duong-le , I recommend to try deleting all node_modules & re-install, sometimes this method works for me. my pkgs are

"@types/chart.js": "2.9.32",
"chart.js": "~2.9.4",
"ng-chartjs": "~0.2.2",
duongleh commented 3 years ago

@ganesh-vellanki thanks for your suggestion. I did remove node_modules and did a fresh installation. I think I'm gonna try it one more time later and give feedback.

93Alliance commented 3 years ago

Hi @93Alliance I am able to install latest 0.2.2 & run existing project without any issues, thanks for the update! I have a question though, Are you planning on releasing new version to support chartjs 3.. ?

The next version will support chart.js 3.

patolax commented 3 years ago

@93Alliance

image

I am still getting these error when I tried

"@angular/core": "^11.2.14",
"chart.js": "3.6.0",
"chartjs-plugin-annotation": "1.1.0",
"ng-chartjs": "0.2.3",
"@types/chart.js": "2.9.34",

I also tried "chart.js": "3.2.1", but still the same error.

Any idea what I am doing wrong.

93Alliance commented 3 years ago

@93Alliance

image

I am still getting these error when I tried

"@angular/core": "^11.2.14",
"chart.js": "3.6.0",
"chartjs-plugin-annotation": "1.1.0",
"ng-chartjs": "0.2.3",
"@types/chart.js": "2.9.34",

I also tried "chart.js": "3.2.1", but still the same error.

Any idea what I am doing wrong.

image

Chart.js 3.0 is not currently supported.

timon0305 commented 2 years ago

ng-chartjs is not working on Angular v10. They say there is missing dependencies.

timon0305 commented 2 years ago
Screen Shot 2022-03-18 at 7 04 09 PM
93Alliance commented 2 years ago

First I suggest you use Angular 11. Currently ng-Chartjs does not match Angular 10. I will release a special version for Angular10 in my spare time.