當我嘗試加載我的網站我WAMP的服務器上,它給了我這個錯誤:谷歌可視化API - 錯誤:未知的頭型:1
Error: Unknown header type: 1
https://www.google.com/uds/api/visualization/1.0/c3581c99759b4a64cb69ca21ab634266/format+en,default+en,ui+en,corechart+en.I.js
Line 171
這是我的代碼:
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>SO Q#</title>
<style type="text/css">
html {
height: 100%;
width: 100%
}
body {
height: 100%;
width: 100%;
margin: 0;
padding: 0
}
#chart {
height: 100%;
width: 100%
}
</style>
<script language="javascript" type="text/javascript" src="https://www.google.com/jsapi"></script>
<script language="javascript" src="../js/jquery.js"></script>
<script language="javascript" src="../js/jquery.csv.js"></script>
<script language="javascript" type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
$.get("https://docs.google.com/spreadsheet/pub?key=0Ao6fMN9Cw0GPdFVtZ29iYmd1cmRORU0yemYxUjE3OVE&single=true&gid=0&output=csv", function(csvString) {
var arrayData = $.csv.toArrays(csvString, {onParseValue: $.csv.hooks.castToScalar});
var data = new google.visualization.arrayToDataTable(arrayData);
var view = new google.visualization.DataView(data);
view.setColumns([0,1]);
var options = {
title: "A Chart from a CSV!",
legend: 'none'
};
var chart = new google.visualization.PieChart(document.getElementById('chart'));
chart.draw(view, options);
});
}
</script>
</head>
<body>
<div id="chart"></div>
<script>
</script>
</body>
</html>
誰能告訴我這個錯誤來自哪裏?
嘗試從瀏覽器中的$ .get()調用打開https鏈接。你必須從該網站獲取'testchart.csv'文件。 –
我收到了這個文件。現在我將代碼更改爲:「$ .get(」testchart.csv「,function(csvString){」,是這樣嗎? – user3040943
是的,如果該文件與您的html文件位於相同的目錄中 –