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]> 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].
> To post to this group, send email to
> [email protected].
> 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 http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to