Trying to create a bar chart using the coin gecko api. Having trouble passing through the api data to the barchart. Getting errors on Label, labels, and data. Any help please. Writing in typescript/js. My code is below.
const data = {
labels: chart.coins?.map(x => x.name),
datasets: [{
label: `${chart?.coins?.length} Coins Available`,
data: chart?.coins?.map(x => x.price),
backgroundColor: [
'rgba(255, 99, 132, 0.2)',
'rgba(54, 162, 235, 0.2)',
'rgba(255, 206, 86, 0.2)',
'rgba(75, 192, 192, 0.2)',
'rgba(153, 102, 255, 0.2)',
'rgba(255, 159, 64, 0.2)'
],
borderColor: [
'rgba(255, 99, 132, 1)',
'rgba(54, 162, 235, 1)',
'rgba(255, 206, 86, 1)',
'rgba(75, 192, 192, 1)',
'rgba(153, 102, 255, 1)',
'rgba(255, 159, 64, 1)'
],
borderWidth: 1
}]
};
coingecko
or remove your example code's dependency on it. Also, please provide a minimal reproducible example suitable for pasting into a standalone IDE. Good luck! - jcalz