PieCharts require one string column and one number column - you have two
number columns. Change the type of the first column to "string" and it
should work (the values in that column are already strings, so it should be
fine):
{"label":"idade","type":"string"}
On Sunday, January 12, 2014 10:48:28 PM UTC-5, Amanda Beloli wrote:
>
> Hi all,
>
> I'm almost sure that my json table generated by my script.php is right:
>
>
> {"cols":[{"label":"idade","type":"number"},{"label":"quantidade","type":"number"}],"rows":[{"c":[{"v":"19"},{"v":1}]},{"c":[{"v":"20"},{"v":1}]},{"c":[{"v":"25"},{"v":1}]},{"c":[{"v":"37"},{"v":1}]},{"c":[{"v":"45"},{"v":2}]}]}
>
> But anything appear when I tried to create the chart, by means of the code
> below. Anybody knows the problem?
>
> <html>
>> <head>
>> <!--Load the AJAX API-->
>> <script src="http://code.jquery.com/jquery-latest.js"></script>
>> <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: "script.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.PieChart(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"></div>
>> </body>
>> </html>
>
>
> I suppose it is not the problem, but I'm using wamp server... not using
> databases, json and these stuffs, google charts works nicely with php in
> wamp.
>
> Thank you in advance.
>
--
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.