我剛剛在Google Visualization group中發佈了這個消息,但我想我也會向Plone社區尋求幫助。Google Visualization和Plone - 「e [0] .K is undefined」錯誤信息
我正在使用Plone 4.2.4,並希望通過cx_Oracle將Google Charts與Oracle後端集成。已經有一個非常好的軟件包叫做EEA.Daviz。然而,它遠比我需要的多,我認爲我可以自己做,所以我創建了一些頁面模板和包裝Javascript的Python代碼。在我的筆記本電腦上(Mac OS X),它一切正常。
但是,一旦我將其推送到我的服務器(SLES 10),BarCharts停止工作。我只測試過Bar,Line和Motion圖表。我所得到的只是一個紅色的錯誤框,表示「e [0] .K未定義」。谷歌搜索後,我發現我的問題a very similar description,這表明它是一個谷歌的可視化錯誤,修復是改變寬度和高度屬性。但是,更改高度或寬度並未解決問題。非常奇怪的是,如果我從BarChart頁面複製示例JS並將其複製到一個vanilla Zope頁面模板中,它就可以正常工作。但是,一旦我將它包裝在主模板中,我又收到紅色錯誤消息。
所以我很困惑。我在我的筆記本電腦上安裝了相同的主題,並沒有給我帶來任何問題。我知道我可以在服務器上顯示BarCharts,而無需在香草頁面模板中使用主題。
任何人都可以指向正確的方向嗎?
ZPT的作品:
<html>
<head>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script>
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['COUNTRY', ' COUNT'],
['Austria', 19],
['Belgium', 73],
['Bulgaria', 20]]
); var options = {
title: 'Test Bar Chart'}; var chart = new google.visualization.BarChart(document.getElementById('chart_div'));
chart.draw(data, options);}
</script>
</head>
<body>
<div id="chart_div" style="width: 900px; height: 1000px;"></div>
</body>
</html>
ZPT不工作:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
lang="en"
metal:use-macro="context/main_template/macros/master"
i18n:domain="plone">
<metal:main fill-slot="javascript_head_slot">
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script>
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['COUNTRY', ' COUNT'],
['Austria', 19],
['Belgium', 73],
['Bulgaria', 20]]
); var options = {
title: 'Test Bar Chart'}; var chart = new google.visualization.BarChart(document.getElementById('chart_div'));
chart.draw(data, options);}
</script>
</metal:main>
<body>
<metal:main fill-slot="main">
<tal:main-macro metal:define-macro="main">
<div id="chart_div" style="width: 900px; height: 1000px;"></div>
</tal:main-macro>
</metal:main>
</body>
</html>
我發現,由於某些原因禁用kupuhelpers.js導致錯誤走開。我意識到我的筆記本電腦上安裝了TinyMCE,而不是Kupu。很奇怪!任何想法爲什麼kupuhelpers.js會阻止它? – waldopat