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>
我現在的問題是,我的圖表沒有得到正確顯示,並在左側切斷。有時我得到一個錯誤:「無法獲取未定義或空引用的屬性」日誌「(我可以通過隨機關閉和重新打開對話框和切換標籤重現該錯誤)。
您能否幫我找到我的問題或提供解決方案,以便如何在模態對話框中正確包含Google可視化圖表?
編輯:時間軸工作正常,不包括在對話框中。當我在瀏覽器中打開「timeline.php」時,一切看起來都很好。只有與對話框或選項卡或兩者都有問題?!