I'm using the Facebook Graph API to get the likes from a person, and I want to use google charts to graph it. But unfortunately, I'm a bit lost on how to do it.
The Array response.likes.data from facebook has this format:
[{"name":"Death Stranding","category":"Video Game","id":"1583509281947417"},{"name":"Ryan Gosling","category":"Artist","id":"246631252031491"},{"name":"The Nice Guys","category":"Movie","id":"1668045260089410"},{"name":"The Tonight Show Starring Jimmy Fallon","category":"TV Show","id":"31732483895"},{"name":"Hardcore Henry","category":"Movie","id":"653090358094272"},{"name":"Bronson","category":"Movie","id":"237617070301"}]
But I think I need to format it like this for the Google Chart:
var data = google.visualization.arrayToDataTable([
['Categories', 'Likes count'],
['Films', 11],
['Brands', 2],
['TV Shows', 2],
['Artists', 2],
['Music', 7]
]);
Where both the categories and count of likes would be variables, since I don't know beforehand what the response will be.
Using for and push, I managed to get the distinct categories on an array. But I don't know how to count how many likes each of those categories has, and even less how to format it like [category, count].
I'm very new to this and trying to learn how to code, so I will really appreciate any inputs you have.
Thanks in advance.