我在尝试使用Google Charts API构建带注释的时间线图时遇到问题.
在JSON中,对于第一个"日期"列,如果我使用:
"v": new Date(2010, 01, 01)
然后我从我的页面收到一个JavaScript错误,说我有无效的JSON.
如果相反我使用:
"v": "new Date(2010, 01, 01)"然后我得到了错误TypeError: 'undefined' is not a function (evaluating 'M[y]()').
我的JavaScript代码只是对Pie Graph的示例代码的修改,该代码位于:http://code.google.com/apis/chart/interactive/docs/php_example.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<!--Load the AJAX API-->
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript" src="scripts/jquery-1.6.2.js"></script>
<script type="text/javascript">
// Load the Visualization API and the piechart package.
google.load('visualization', '1', {'packages':['annotatedtimeline']});
// Set a callback to run when the Google Visualization API is loaded.
google.setOnLoadCallback(drawChart);
function …Run Code Online (Sandbox Code Playgroud)