Chartjs-Count all distinct values from JSON in javascript for ChartJS

0👍

You can try

 const hometownCount = apiCallResult.reduce((acc, it) => {
   acc[it.hometown] = (acc[it.hometown] || 0) + 1;
   return acc;
 }, {});

Hope this helps.

0👍

After a quick search, I found out I was on the right track. I needed Object.keys(hometown) and Object.values(hometown) to put in Chartjs for things to work.
Cheers

Leave a comment