0
早上好!Google可視化運動圖未定義?
今天早上我遇到了一個問題,我向應用程序添加了Google Visualization Motion Chart。但像大多數情況下,它不符合瀏覽器標準。在FF3中,它工作正常,但在Safari和IE 7中,錯誤控制檯顯示:「TypeError:表達式結果'google.visualization'[undefined]不是一個對象。」
我不知道它爲什麼會發生,或者我可以在我的代碼中進行更改。這是我使用的代碼片段。感謝您的幫助!
<div id="NRG-motion-chart" style="width: 625; height: 625px;"></div>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load('visualization', '1', {'packages':['motionchart']});
google.setOnLoadCallback(drawChart);
function drawChart() {
var nrgChart = new google.visualization.DataTable();
nrgChart.addColumn('string', 'Business Unit');
nrgChart.addColumn('date', 'Date');
nrgChart.addColumn('number', 'Sales');
nrgChart.addColumn('number', 'Covers');
nrgChart.addColumn('number', 'Sales Per Man Hour');
nrgChart.addColumn('number', 'Labor Hours Per Cover');
nrgChart.addColumn('string', 'Location');
nrgChart.addRows([<?= $gData['gData']; ?> ]);
var chart = new google.visualization.MotionChart(document.getElementById('NRG-motion-chart'));
chart.draw(nrgChart, {width: 625, height:625});
}
</script>