Step in Creating charts in Ionic:
Step 2: Add following code in home.html.
We have 3 cards, each card has an element
, and we add a local variable like so
that we can easily grab a reference to it from our TypeScript file.
Add following code in home.ts
Notice: –that we are importing Chart, and we are also importing ViewChild. We use ViewChild to grab a reference to the local variable we attached to the canvas in the template, and then we supply that element to new Chart when we are creating a chart. All we have to do is supply Chart with an object that defines the type of chart we want, and the type of data we want to display.
We don’t have to add anything to app.module.ts file.