1

dialog.php包括jQuery UI的標籤包括谷歌的可視化時間軸失敗

<div id="tab2"> 
<iframe width="100%" height="80%" src='timeline.php'/> 
</div> 

timeline.php

$timeline = getData($_dbo, 'somefilter1', 'otherfilter1'); // getData selects data from a DB 

?> 
<html> 
    <head> 
    <script type="text/javascript" src="https://www.google.com/jsapi"></script> 
    <script type="text/javascript"> 
     google.load("visualization", "1", {packages:["timeline"]}); 
     google.setOnLoadCallback(drawChart); 

     function drawChart() { 
     var container = document.getElementById('timeline'); 
     var chart = new google.visualization.Timeline(container); 
     var dataTable = new google.visualization.DataTable(); 

     dataTable.addColumn({ type: 'string', id: 'State' }); 
     dataTable.addColumn({ type: 'date', id: 'Start' }); 
     dataTable.addColumn({ type: 'date', id: 'End' }); 

     dataTable.addRows([  
     <? 
     $c = 0; $state = array(); 
     foreach($timeline as $row) 
     { 
      if(count($state) == 0) 
      { 
       $state['s'] = $row['CurrentStatus']; 
       $state['r'] = $row['Rank']; 
       $state['start'] = "new Date(".$row['HYear'].", ".$row['HMonth'].", ".$row['HDay'].")"; 
      } 

      if($row['CurrentStatus'] != $state['s'] || $timeline[$c]['ClosedDate'] != '') 
      { 
       $date = "new Date(".$row['HYear'].", ".$row['HMonth'].", ".$row['HDay'].")"; 
       $currentstate = $state['r'].' '.$state['s']; 
       ?> 
       [ '<?= $currentstate ?>', <?= $state['start'] ?>, <?= $date ?> ]<? 
       if ($c < count($timeline) && $timeline[$c]['ClosedDate'] == '') echo ",\r\n"; 

       $state['s'] = $row['CurrentStatus']; 
       $state['r'] = $row['Rank']; 
       $state['start'] = "new Date(".$row['HYear'].", ".$row['HMonth'].", ".$row['HDay'].")"; 
      } 

      if($timeline[$c]['ClosedDate'] != '') break;    
      $c++; 
     } 
     ?>  
     ]); 


     chart.draw(dataTable); 
     } 
    </script> 
    </head> 
    <body> 
    <div id="timeline" style="height: 180px; width:100%;"></div> 
    </body> 
</html> 

我現在的問題是,我的圖表沒有得到正確顯示,並在左側切斷。有時我得到一個錯誤:「無法獲取未定義或空引用的屬性」日誌「(我可以通過隨機關閉和重新打開對話框和切換標籤重現該錯誤)。

mytimeline 您能否幫我找到我的問題或提供解決方案,以便如何在模態對話框中正確包含Google可視化圖表?

編輯:時間軸工作正常,不包括在對話框中。當我在瀏覽器中打開「timeline.php」時,一切看起來都很好。只有與對話框或選項卡或兩者都有問題?!

回答

0

我設法找到解決方案。所以我想我會回答我自己的問題。我改變了我的標籤內容不包括iframe中,但常規的DIV像這樣:

<div id="tab2"><div id="timelinediv"></div></div> 

,我用在同一頁上我的JavaScript,所以我沒有從另一個網頁包含它。 也許不是最好的可讀解決方案,但它爲我工作。