The JSON string returned 
by 
http://data.police.uk/api/crimes-street/all-crime?lat=52.629729&lng=-1.131592&date=2013-01
 
is not in the correct format for the Google Visualization API.  Also, the 
json contains many categories of data, while the PieCharts expect to see 
two columns of data: one "string" type for pie slice labels and one 
"number" type for pie slice values.  What data do you want to chart?

On Friday, January 24, 2014 10:31:53 AM UTC-5, Stelios Voskos wrote:
>
> I have to visualize some url json data on a pie chart with google 
> visualization. My code seems to be as it has to be for the purpose, but I 
> am getting an 'Invalid row type for row 0' error in the console. Is there 
> any problem with the format of the data? If there is anyone that could 
> help, that would be much appreciated. Here is my code:
>
> PHP:
>
> <?php
>     $json = 
> file_get_contents('http://data.police.uk/api/crimes-street/all-crime?lat=52.629729&lng=-1.131592&date=2013-01');
>  
>     $json = str_replace("\xe2\x80\xa8", '\\u2028', $json);
>     $json = str_replace("\xe2\x80\xa9", '\\u2029', $json);
>     echo $json;?>
>
> JavaScript:
>
> <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']});
> // 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 an array of the JSON data and then create our data table out of 
> JSON data loaded from server.
>   var array = JSON.parse(jsonData);
>   var dataTableData = new google.visualization.arrayToDataTable(array);
>   var table = google.visualization.DataTable(dataTableData);
>
>   var chart = new 
> google.visualization.PieChart(document.getElementById('chart_div'));
>   chart.draw(data, {width: 400, height: 240});}
> </script></head>
> <body><div id="chart_div"></div></body>
>
> Thank you.
>

-- 
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