Search code examples
angularnpmchart.jsng2-chartscumulocity

Using Chart.js and Ng2-Chart in Cumulocity


I am currently building an Angular application to be hosted on the Cumulocity IoT platform, and I am trying to use Chart.js to generate custom bar charts. This did not work at first, so I did a little digging and discovered the special node package, ng2-chart, developed to employ Chart.js with Angular.

As it happens, I installed the latest version of each dependency, but I soon encountered errors trying to build and serve the application, among which is NG8002 that states:

Error: src/app/features/[..].component.html:81:17 - error NG8002: Can't bind to 'legend' since it isn't a known property of 'canvas'.

I did some research and found that this is likely due to the latest versions of Chart.js and ng2-chart being incompatible with my current development environment:

  • @angular/cli: 14.2.12
  • npm: 6.14.18
  • c8y/client: 1016.0.324

Has anyone else encountered this problem? What versions of Chart.js and ng2-chart could I use for my application?


Solution

  • i leave you a small image of the versions compatible with ng2-chart and an installation guide

    enter image description here

    Installation Guide

    https://www.npmjs.com/package/ng2-charts