我试图通过Google Charts传递数据,并且我在控制台中收到错误,其中显示" Uncaught Error:给定的每一行必须为null或数组。"
我在stackoverflow上发现了这篇文章,但它似乎并不适用。 Dynamic data with Google Charts。我的代码如下。
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"}
]);
我做错了什么?
答案 0 :(得分:2)
好吧,看起来你正在添加对象作为你的行。
如果你这样做
data.addrows([
["3.44", "VZ"],
["6.95", "XOM"],
...
]);