How to apply data dynamically on initialisation for chart.js in angular?

0👍

Everything is correct, just put the graph initialization inside .subscribe(...).

Otherwise you can put it in another function and call it inside the subscribe() method.

this.httpService.getBodyweight().subscribe(response => 
  {
      this.bodyweightData.push(response)ù
      //Build graph here or call a function that builds it
  })

This is because the code after the server call is run before the response actually arrives, so the variable you are using to build the graph is still empty

Leave a comment