[Chartjs]-The chart in angular is not re-rendering when i change the input data

2👍

Based on the code you provided, the issue is that the child component is not being notified about the changes in the dropdown selection. To fix it, you can add ngOnChanges() method to the child component to update the chart whenever the label is changed:

ngOnChanges(changes: SimpleChanges) {
    if (changes['labels'] && this.chart) {
        this.chart.data.datasets = this.dataSets;
        this.chart.data.labels = this.labels;
        this.chart.update();
    }
}

Leave a comment