Google charts “Row given with size different than” when data.addRows from var

杀马特。学长 韩版系。学妹 提交于 2020-01-15 03:48:26

问题


im trying to create bar chart and but for some reason,it dosnt work.

when i copy past data to data.addRows method it working fine but when i insert the data to var rawData im receiving

Row given with size different than 8 (the number of columns in the table). 

this is the code:

    data.addColumn('number', 'Time');
    data.addColumn('number', 'a');
    data.addColumn('number', 'b');
    data.addColumn('number', 'c');
    data.addColumn('number', 'd');
    data.addColumn('number', 'e');
    data.addColumn('number', 'f');
    data.addColumn('number', 'g');
    data.addRows([[rawData]]); 

and this is the value of console.log(rawData);

[8,0,0,0,0,0,0,2],[9,0,0,3,0,1,0,2],[10,0,0,20,0,1,0,7],[11,13,0,24,2,7,0,16],[12,0,1,23,2,3,0,1],[13,2,4,31,2,0,0,6],[14,0,0,53,0,2,0,4],[15,0,1,57,2,2,0,13],[16,0,0,46,0,7,0,6],[17,0,0,61,0,0,0,7],[18,0,0,15,3,2,0,3],[19,0,0,0,1,0,0,182],[21,0,2,0,0,0,0,305],[23,0,0,0,0,6,0,1]

thanks

miki


回答1:


rawData is already defined as array of arrays so you have to call:

data.addRows(rawData); 

instead of

data.addRows([[rawData]]); 



回答2:


changing data.addRows([graphcontent[0]]); to data.addRows(graphcontent[0]); fixed the error for me.




回答3:


rawData is already defined as array so you have to call:

data.addRows([rawData]);

It should not like data.addRows([[rawData]]); or data.addRows(rawData);



来源:https://stackoverflow.com/questions/20840251/google-charts-row-given-with-size-different-than-when-data-addrows-from-var

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!