Hi, Did you receive these errors?
The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must be declared in the document or in the transfer protocol. exampleUsingPHP.html ReferenceError: $ is not defined drawChart() Any help on this would be great. Thanks, Jess On Thursday, November 7, 2013 at 4:38:50 PM UTC, SAP wrote: > > more details: > > html: > > <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':['timeline']}); > > // 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; > // var newData = JSON.parse(jsonData); > > // Create our data table out of JSON data loaded from server. > var data = new google.visualization.DataTable(JSON.parse(jsonData)); > > // Instantiate and draw our chart, passing in some options. > var chart = new > google.visualization.Timeline(document.getElementById('chart_div')); > chart.draw(data, {width: 1000, height: 600}); > } > > </script> > </head> > > <body> > <!--Div that will hold the pie chart--> > <div id="chart_div"></div> > </body> > </html> > > PHP: > > <?php > > // This is just an example of reading server side data and sending it to > the client. > // It reads a json formatted text file and outputs it. > > $string = file_get_contents("sampleData.json"); > echo $string; > > // Instead you can query your database and parse into JSON etc etc > > ?> > > > > > On Thu, Nov 7, 2013 at 9:51 PM, Sandeep Ambekar <[email protected] > <javascript:>> wrote: > >> Hi.. >> >> I am looking to pull data for timeline from a JSON file. I get below >> error. Please help in fixing this. >> >> ERROR: >> >> Uncaught Error: Invalid JSON string: >> >> >> JSON file used. >> >> { >> "cols": [ >> {"id":"Room","label":"Room","pattern":"","type":"string"}, >> {"id":"Name","label":"Name","pattern":"","type":"string"} >> {"id":"Start","label":"Start","pattern":"","type":"date"}, >> {"id":"End","label":"End","pattern":"","type":"date"} >> ], >> "rows": [ >> {"c":[{"v":"WATCH","f":null},{"v":"TODAYS","f":null},{"v": new >> Date(2013,10,10,01,46,0),"f":null},{"v": new >> Date(2013,10,10,06,31,0),"f":null}]}, >> {"c":[{"v":"WATCH","f":null},{"v":"AVERAGE","f":null},{"v": new >> Date(2013,10,10,01,52,0),"f":null},{"v": new >> Date(2013,10,10,06,37,0),"f":null}]} >> >> ] >> } >> >> -- >> You received this message because you are subscribed to a topic in the >> Google Groups "Google Visualization API" group. >> To unsubscribe from this topic, visit >> https://groups.google.com/d/topic/google-visualization-api/DhqFqPJQQv0/unsubscribe >> . >> To unsubscribe from this group and all its topics, send an email to >> [email protected] <javascript:>. >> To post to this group, send email to [email protected] >> <javascript:>. >> Visit this group at >> http://groups.google.com/group/google-visualization-api. >> For more options, visit https://groups.google.com/groups/opt_out. >> > > -- You received this message because you are subscribed to the Google Groups "Google Visualization API" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/google-visualization-api. To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/71ee5555-1fcb-4276-8cff-1d0498451869%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
