繁体   English   中英

谷歌时间线图表连接到PHP MySQL的

[英]google timeline chart connect to php mysql

现在,我的时间轴图表根本没有显示在我的网页中,我不确定代码的问题是否没有给我任何错误。

我认为这可能与我设置的日期格式有关,但我不确定。 我仔细检查了日期格式,我使用的日期格式与我的数据库匹配。

如果您能指出哪里出错了,我将不胜感激。 谢谢

<?php
$sth = "SELECT * FROM goal WHERE account_id =$account_id";
$result4 = mysqli_query($con,$sth) or die(mysqli_error());
$rows = array();
$flag = true;
$table = array();
$table['cols'] = array(
  array('type' => 'string', 'label' => 'goalName'),
    array('type' => 'date', 'label' => 'starts'),
    array('type' => 'date', 'label' => 'finish'));

//$rows = array();
while($rows = mysqli_fetch_assoc($result4)) {
$temp = array();
$starts = date("Y-m-d"); 
$finish = date("Y-m-d"); 

$temp[] = array('v' => (string) $rows['goalName']); 
$temp[] = array('v' => (string) $rows['starts']); 
$temp[] = array('v' => (string) $rows['finish']); 
$rows[] = array('c' => $temp);}

$table['rows'] = $rows;
$jsonTable = json_encode($table);
//echo $jsonTable;
?>


<script type="text/javascript" src="https://www.google.com/jsapi?autoload={'modules':    [{'name':'visualization',
   'version':'1','packages':['timeline']}]}"></script>
<script type="text/javascript">

google.setOnLoadCallback(drawChart);
function drawChart() {

var container = document.getElementById('example3.1');
var chart = new google.visualization.Timeline(container);
var dataTable = new google.visualization.DataTable();
var data = "" google.visualization.DataTable(<?php echo json_encode($table,  JSON_NUMERIC_CHECK); ?>);

var options = {
    title: 'Progress',
    is3D: true
var options = {
timeline: { colorByRowLabel: true }
};

chart.draw(dataTable, options);
}

</script>

朋友的细节在var选项中被解释了两次,因此您会看到:

var options = {

    title: 'Progress',
    is3D: true
var options = {

timeline: { colorByRowLabel: true }

};

并应如下所示

var options = {

    title: 'Progress',
    is3D: true,
     timeline: { colorByRowLabel: true }
};

希望对您有帮助

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM