K
K
Kostya Ostapuk2018-02-18 21:44:54
JavaScript
Kostya Ostapuk, 2018-02-18 21:44:54

How to update chartjs + angular 5 chart?

<chart [type]="type" [data]="data" [options]="options"></chart>

ngOnInit() {
    this.checkChartData();
    this.type = 'line';
    this.data = {
      labels: ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday', 'Saturday',],
      datasets: [
        {
            ...
            data: this.commitsData, // это массив у меня 
        }
    ]
    };

With the help of js I would do it, but I don’t know how to use it in Angular, please help

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Eugene, 2018-02-18
@evgshk

To update the chart, you need to update the linked data, if I understand the question correctly.

V
Vladimir, 2018-02-18
@Casufi

The question is how to update the chart when the input data changes?
As I understand it, you need to implement redrawing in ngOnChanges
https://angular.io/guide/lifecycle-hooks

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question