Skip to content

Instantly share code, notes, and snippets.

@desoga10
Created March 22, 2023 15:27
Show Gist options
  • Save desoga10/e081437c70a4e53aa3d2e4801447a66c to your computer and use it in GitHub Desktop.
Save desoga10/e081437c70a4e53aa3d2e4801447a66c to your computer and use it in GitHub Desktop.
ngOnInit() {
this.service.cryptoData().subscribe((res) => {
this.result = res;
this.coinPrice = this.result.data.coins.map((coins: any) => coins.price);
this.coinName = this.result.data.coins.map((coins: any) => coins.name);
console.log(this.coinPrice);
console.log(this.coinName);
this.chart = new Chart('canvas', {
type: 'bar',
data: {
labels: this.coinName,
datasets: [
{
data: this.coinPrice,
borderColor: '#3e95cd',
label: 'Coin Price',
backgroundColor: 'rgba(93, 175, 89, 0.1)',
borderWidth: 3,
},
],
},
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment