I am using ionic 2.
I need to get HTML element value.
Actually, I used viewchild.
Here is my html template code
I got this issue to display bar chart in ionic angular 9 project. My issue was resolved after adding timeout function
@ViewChild('barChart') barChart;
ngOnInit() {
setTimeout(() => {
this.createBarChart();
}, 1000);
}
createBarChart() {
this.bars = new Chart(this.barChart.nativeElement, {
type: 'bar',
data: {
labels: this.chartLabels,
datasets: [{
label: 'Monthly Costings',
data: [2.5, 3.8],
backgroundColor: ['rgb(38, 194, 100)', '#548279'],
borderColor: ['rgb(38, 194, 100)', '#548279'],
borderWidth: 1
}]
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero: true
}
}]
}
}
});
}