Chartjs-Unable to display data in Bar Chart using react-chart-2

0👍

The problem is that you’re adding the data at the wrong place.

barchart.datasets.data = data.map(x => { return x["bytes"]})

barchart.datasets is an array that contains a single dataset in your case. Therefore, this should be rewritten as follows:

barchart.datasets[0].data = data.map(x => { return x["bytes"]})

This can be simplified in the following way:

barchart.datasets[0].data = data.map(x => x["bytes"])

Leave a comment