May I seek you help on the challenge I have been facing. I tried to create a barchart with a Dynamic Data from the Database the outputs for labels was ["11/22/18","11/26/18","11/27/18","11/28/18"] and for data was [42,304,464,54] but apparently it is not working upon the API result. Here's my function
loadData(){
let loader = this.loadCtrl.create({
spinner: 'bubbles',
content: "Loading Wallet"
});
loader.present();
let data:Observable<any>;
data = this.http.get('apiurl');
data.subscribe(result => {
this.items = result;
this.value = result[0].Dates;
this.value1 = result[0].Value;
console.log(this.value);
console.log(this.value1);
this.barChart = new Chart(this.barCanvas.nativeElement, {
type: 'bar',
data: {
labels: this.value,
datasets: [{
label: 'Monthly',
data: this.value1,
borderWidth: 1
}]
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero:true
}
}]
}
}
});
loader.dismiss();
})
}
Thank you.
Comments
Post a Comment