2013-04-17 29 views
0

我剛剛在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> 
+0

我發現,由於某些原因禁用kupuhelpers.js導致錯誤走開。我意識到我的筆記本電腦上安裝了TinyMCE,而不是Kupu。很奇怪!任何想法爲什麼kupuhelpers.js會阻止它? – waldopat

回答

0

我測試過你的第二個例子,它似乎以達到預期效果,所以也許有什麼不對您的來自Oracle的數據(格式,缺失值等)。你必須在那裏做一些JS調試。嘗試添加一個斷點以查看e [0]是什麼以及爲什麼它沒有K屬性(或爲什麼e是一個空數組)。

此外,EEA Daviz是彙集了多種可視化框架(Google ChartsSimile Exhibit並在不久的將來Highcharts),但你可以隨時使用其組件的一個或多個不使整個平面因此,你應該捆綁也嘗試EEA Google Charts。不要忘了,你需要collective.js.jqueryui< 1.9爲Plone 4.2.x版

Testing in Plone

+0

是的,我測試過EEA.Daviz。我有點不確定如何以編程方式將行數據傳遞給EEA Google Charts。我使用CSV數據創建了一個測試,但是我將要設置該字段或從Oracle向Google Charts發送行數據。有小費嗎? – waldopat

+0

另外,請參閱我上面的評論。由於某些原因,禁用kupuhelpers.js會導致錯誤消失。我不知道爲什麼或如何相關,但它的工作原理。 – waldopat