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”时,一切看起来都很好。只有与对话框或选项卡或两者都有问题?!