dtest84004 2014-01-14 13:37
浏览 30

需要帮助解决谷歌图表时间线中的神秘消息['undefined'不是对象(评估'this.Vn [0] .v')]

I am having trouble getting Google Charts Timeline working with JSON/PHP. Initially I got an error that said "3 or 4 columns is required" so I fixed up the data but now I am getting the following cryptic error message:

['undefined' is not an object (evaluating 'this.Vn[0].v')]

My guess is there is something wrong with my JSON. Here is the output of my PHP script which provides the data:

{ "cols": 
[ {"id":"a","label":"Col1","pattern":"","type":"string"},
  {"id":"b","label":"Col2","pattern":"","type":"string"},
  {"id":"c","label":"Start","pattern":"","type":"date"},
  {"id":"d","label":"Stop","pattern":"","type":"date"} 
],
    "rows": 
    [ 
      {"c":[{"v":"test1","f":null},
            {"v":"test2","f":null},
            {"v":"2009-04-12T20:44:55","f":null},
            {"v":"2009-04-12T20:45:55","f":null}
            ]
      }, 
     ] 
}

Here is part of the main page's HTML/JS in case it is relevant.

<html>
  <head>


<!--Load the AJAX API-->
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">

// Load the Visualization API and the piechart package.
google.load('visualization', '1', {'packages':['corechart','table','timeline']});

// Set a callback to run when the Google Visualization API is loaded.
google.setOnLoadCallback(drawChart);
  function drawChart() {
  var jsonData = $.ajax({
      url: "ar2_1_data.php",
      dataType:"json",
      async: false
      }).responseText;

  // Create our data table out of JSON data loaded from server.
  var data = new google.visualization.DataTable(jsonData);

  // Instantiate and draw our chart, passing in some options.
  var chart = new google.visualization.Timeline(document.getElementById('chart1_div'));
  chart.draw(data, {width: 500, height: 320, title: 'Timeline'});
}

</script>
</head>

<body>
  <div id="chart1_div"></div>
</body>
</html>

Can anyone help me figure out what this error message means?

  • 写回答

1条回答 默认 最新

  • dptdb84606 2014-01-14 14:22
    关注

    My problem was the dates were not in the right format. I used the following code and put the resultant string inside of "Date(...)".

    $stopdate = DateTime::createFromFormat('Y-m-d H:i:s', $row['STOPTIME']);
    $stopfor = $stopdate->format('Y,m,d,H,i,s');
    
    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大