2
這裏是一些代碼字面從https://developers.google.com/chart/interactive/docs/drawing_charts#chartwrapper
它應該顯示一個ColumnChart,但它不會產生任何輸出。相反,會發生JavaScript錯誤。
當加載文件獨立時,錯誤是loader.js:135 Uncaught TypeError: Cannot read property 'length' of undefined
在loader.js:135
任何想法如何解決這個問題?無法使google.visualization.ChartWrapper示例工作
<html>
<head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current'); // Don't need to specify chart libraries!
google.charts.setOnLoadCallback(drawVisualization);
function drawVisualization() {
var wrapper = new google.visualization.ChartWrapper({
chartType: 'ColumnChart',
dataTable: [['', 'Germany', 'USA', 'Brazil', 'Canada', 'France', 'RU'],
['', 700, 300, 400, 500, 600, 800]],
options: {'title': 'Countries'},
containerId: 'vis_div'
});
wrapper.draw();
}
</script>
</head>
<body style="font-family: Arial;border: 0 none;">
<div id="vis_div" style="width: 600px; height: 400px;"></div>
</body>
</html>