I'm trying to pass data with Google Charts and I am getting an error in the console that reads "Uncaught Error: Every row given must be either null or an array."
I found this post on stackoverflow already however it doesn't seem to be applicable. Dynamic data with Google Charts . My code is below.
function drawChart() {
// Create the data table.
var data = new google.visualization.DataTable();
data.addColumn('string', 'Topping');
data.addColumn('number', 'Slices');
data.addRows([
{"somePercentage":"3.44","someId":"VZ"
},
{"somePercentage":"6.95","someId":"XOM"
},
{"somePercentage":"5.55","someId":"GG"
},
{"somePercentage":"10.53","someId":"INTC"
},
{"somePercentage":"8.39","someId":"TD"
},
{"somePercentage":"5.59","someId":"VOD"
},
{"somePercentage":"12.67","someId":"ARII"
},
{"somePercentage":"17.73","someId":"VVVVA"
},
{"somePercentage":"21.81","someId":"BSV"
},
{"somePercentage":"7.34","someId":"VNM"}
]);
What am I doing wrong?
Well, looks like you're adding objects as your rows.
what if you do
data.addrows([
["3.44", "VZ"],
["6.95", "XOM"],
...
]);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.