I'm trying to use Google's chart: http://ift.tt/1ppbI5g
I have some objects inside another object that I want to insert into the table. My question is this: do I have to put them into an array?
My code so far:
How do I get the objects from a JSON file:
function getTotalBundles() {
var totalBundles = {};
for (var i = 0, max = users.length; i < max; i++) {
var user = users[i];
for (var bundle in user.bundles) {
if (user.bundles.hasOwnProperty(bundle)) {
if (!totalBundles[bundle])
totalBundles[bundle] = 0;
++totalBundles[bundle];
}
}
}
return totalBundles;
}
function drawTable() {
var data = new google.visualization.DataTable();
var temp = getTotalBundles();
data.addColumn('string', 'Name');
data.addColumn('number', 'Purchased');
data.addRows(....);
}
Aucun commentaire:
Enregistrer un commentaire