score:0

Accepted answer

you have to create a config variable like this:

public config = {
    type: 'bar',
    legend: true,
    data: {
      labels: [ "incoming" , "missed" , "outgoing"],
      datasets: [{
        label: 'calls',
        data: []
      }]
    }
  }

in your html file, put this:

<div style="display: block">
   <canvas id="canvas" style="display: block"></canvas>
</div>

in the ngoninit() function do this (variables ctx and mybarchart must be defined earlier):

this.ctx = document.getelementbyid('canvas') as htmlcanvaselement
this.mybarchart = new chart(this.ctx.getcontext('2d'), this.config)

when you want to update the data, you can do it this way:

this.mybarchart.data.datasets[0].data = your_firebase_data;
this.mybarchart.update()

cheers


Related Query

More Query from same tag