Google图表不接受我的数据-尽管我确实尽力以与示例构建方式完全相同的方式来构建它。
这是Google的示例,可以在我的代码中使用
var data = google.visualization.arrayToDataTable([
['Genre', 'Fantasy & Sci Fi', 'Romance', 'Mystery/Crime', 'General',
'Western', 'Literature', { role: 'annotation' } ],
['2010', 10, 24, 20, 32, 18, 5, ''],
['2020', 16, 22, 23, 30, 16, 9, ''],
['2030', 28, 19, 29, 30, 12, 13, '']
]);
这是我的数组:
0: (7) ["Warengruppe", "Ausstattung", "Baby-Mode Sets", "Babypflege", "Personalisierte Schuhe", "Spielzeug", {…}]
1: (7) ["2018_12", 2972, 43812, 16435, 15480, 18608, ""]
2: (7) ["2019_01", 3527, 41577, 16124, 18132, 17128, ""]
3: (7) ["2019_02", 3671, 33655, 13151, 19623, 13478, ""]
4: (7) ["2019_03", 5931, 44647, 17372, 23101, 21126, ""]
5: (7) ["2019_04", 8737, 40356, 18562, 24440, 23018, ""]
6: (7) ["2019_05", 11400, 44798, 14150, 34773, 26308, ""]
为什么不接受此数组。总是收到消息“轴#0的数据列不能为字符串类型”
答案 0 :(得分:0)
数据在这里看起来很好,
还有更多可能会影响结果的代码吗?
请参阅以下工作片段...
google.charts.load('current', {
packages:['corechart']
}).then(function () {
var data = [
["Warengruppe", "Ausstattung", "Baby-Mode Sets", "Babypflege", "Personalisierte Schuhe", "Spielzeug", {role: 'annotation'}],
["2018_12", 2972, 43812, 16435, 15480, 18608, ""],
["2019_01", 3527, 41577, 16124, 18132, 17128, ""],
["2019_02", 3671, 33655, 13151, 19623, 13478, ""],
["2019_03", 5931, 44647, 17372, 23101, 21126, ""],
["2019_04", 8737, 40356, 18562, 24440, 23018, ""],
["2019_05", 11400, 44798, 14150, 34773, 26308, ""]
];
var dataChart = google.visualization.arrayToDataTable(data);
var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
chart.draw(dataChart);
});
<script src='https://www.gstatic.com/charts/loader.js'></script>
<div id='chart_div'></div>