Created
March 22, 2023 15:27
-
-
Save desoga10/e081437c70a4e53aa3d2e4801447a66c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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