7
我有一個谷歌圖表折線圖,我想顯示一個趨勢線,但它沒有顯示出來。谷歌圖表趨勢線沒有顯示
的數據是從數據庫中取出,並用PHP產生的JavaScript,但所產生的JavaScript是這樣的:
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
// Load the Visualization API and the piechart package.
google.load('visualization', '1.0', {'packages':['corechart']});
// Set a callback to run when the Google Visualization API is loaded.
google.setOnLoadCallback(drawChart);
// Callback that creates and populates a data table,
// instantiates the pie chart, passes in the data and
// draws it.
function drawChart() {
var dataS = new google.visualization.DataTable();
dataS.addColumn('string', 'Dag');
dataS.addColumn('number', 'Poäng');
dataS.addRows([
['1', 32],
['2', 37],
['3', 37],
['4', 40],
['5', 31],
['6', 38],
['7', 28],
['8', 34],
['9', 41],
['10', 41],
]);
var optionsS = {
title: '',
legend: 'none',
hAxis: {title: 'Serie'},
vAxis: {title: 'Poäng'},
pointSize: 4,
trendlines: { 0: {} }
};
// Instantiate and draw our chart, passing in some options.
var chart = new google.visualization.LineChart(document.getElementById('chart_div_series'));
chart.draw(dataS, optionsS);
}
</script>
腳本主要是來自谷歌的圖表例子copypaste。除趨勢線沒有顯示外,圖表工作正常。任何想法爲什麼?
這可能不是你的問題的根源,但你有一個結尾逗號你'dataS.addRows'數組參數的結束,這可能會在某些瀏覽器中導致問題。 –