Я реализую диаграмму из диаграммы js. Ответ в порядке, но я не могу использовать функции объекта диаграммы js, например, update () или reset ().
Я хочу обновить диаграмму, и консоль выдаст мне следующее сообщение об ошибке:
ОШИБКА TypeError: this.myBarChart.update не является функцией
Спасибо!
Мой TS-код:
@Component({
selector: 'app-detail-wasser',
templateUrl: './detail-wasser.page.html',
styleUrls: ['./detail-wasser.page.scss'],
})
export class DetailWasserPage implements OnInit {
@ViewChild('myBarChart', { static: false }) myBarChart;
...
...
showChart() {
this.myBarChart = new Chart(this.myBarChart.nativeElement, {
type: 'bar',
data: {
datasets: [
{
label: 'asd',
data: [
234,
this.abc
],
backgroundColor: this.colorArray,
// this dataset is drawn below
order: 1,
}
],
labels: ['asd', 'abc']
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero: true
}
}]
}
}
});
}
updateChart() {
this.abc = 200;
this.myBarChart.update(); // this function is not working
}