Hi there,
I am having an issue when trying to build an Annotated Timeline Graph
using the Google Visualisation API.
In the JSON, for the first "date" column, if I use:
"v": new Date(2010, 01, 01)
Then I get a JavaScript error from my page saying that I have invalid
JSON.
If instead I use:
"v": "new Date(2010, 01, 01)" then I get the error TypeError:
'undefined' is not a function (evaluating 'M[y]()').
My JavaScript code is simply a modification of the example code for a
Pie Graph found at:
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 drawChart() {
var jsonData = $.ajax({
url: "getData.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.AnnotatedTimeLine(document.getElementById('chart_div'));
chart.draw(data, {width: 400, height: 240});
}
</script>
</head>
<body>
<!--Div that will hold the pie chart-->
<div id="chart_div" style="height: 200px; width:200px;"></div>
</body>
</html>
I am aware that people have had similar problems:
http://groups.google.com/group/google-visualization-api/browse_thread/thread/4cfe7f07e5ef4bcc
http://www.mail-archive.com/google-visua...@googlegroups.com/msg02940.html
However in these threads/pages, the answer seems to be to use "v": new
Date(2010, 01, 01) however this does not work for me.
I'm not sure what I am missing here.
Thanks