valor-software / ng2-charts

Beautiful charts for Angular based on Chart.js
http://valor-software.github.io/ng2-charts/
MIT License
2.32k stars 570 forks source link

Chart components registration errors #1908

Closed ilyakonrad closed 1 week ago

ilyakonrad commented 1 month ago

Version 6 seems to require registering scales, controllers and elements manually like this Chart.register([CategoryScale, LinearScale, BarController, BarElement, LineController, LineElement, PointElement])

otherwise it'll show one error at a time until you register all necessary things image

Here are the errors I've faced: ERROR Error: "category" is not a registered scale ERROR Error: "linear" is not a registered scale ERROR Error: "bar" is not a registered controller ERROR Error: "bar" is not a registered element ERROR Error: "line" is not a registered controller ERROR Error: "line" is not a registered element ERROR Error: "point" is not a registered element

anuj9196 commented 2 weeks ago

If you are not using standalone components, add this to the app.module.ts

providers: [
 provideCharts(withDefaultRegisterables()),
 ...
]