【发布时间】:2011-12-07 05:41:26
【问题描述】:
以下代码可以作为一个独立页面正常工作。但是如果合并到我的 PHP Web 应用程序中,它会引发错误。如果错误发生在谷歌图表JS中,如何调试? 任何建议都会有所帮助
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>
Google Visualization API Sample
</title>
</head>
<body style="font-family: Arial;border: 0 none;">
<div id="myGraphLabel" onclick="drawColumnChart();">
My Column Chart
</div>
<div id="myColumnChart" style="width: 600px; height: 400px;"></div>
</body>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load('visualization', '1', {packages: ['corechart']});
function drawColumnChart() {
// Create and populate the data table.
var data = new google.visualization.DataTable();
data.addColumn('string', 'Task');
data.addColumn('number', 'Hours per Day');
data.addRows(2);
data.setValue(0, 0, 'Work');
data.setValue(0, 1, 11);
data.setValue(1, 0, 'Eat');
data.setValue(1, 1, 2);
// Create and draw the visualization.
new google.visualization.PieChart(document.getElementById('myColumnChart')).
draw(data, {title:"So, how was your day?"});
}
</script>
</html>
Chrome 中的错误:它显示“无法读取未定义的属性'长度'”,容器中有红色背景
Firefox 中的错误: 在 Firebug 控制台中引发错误: b[c] 未定义 http://www.google.com/uds/api/visualization/1.0/97e6275dc5c50efe5944ddda289e59d2/format+en,default,corechart.I.js 785号线
【问题讨论】:
-
您提供的代码运行良好 - 融入 PHP 是什么意思?
-
我的意思是在我的 .ctp 文件中。抱歉,不清楚。我确实发现,由于包含prototype-1.6.0.2.js,它不起作用。 :)
标签: javascript google-visualization