I see you have two google.load() calls, one with a 'callback', and one
without, followed by the setOnLoadCallback.  I'm not sure what that is
going to do, but it doesn't seem like a good idea.

dan


On Sat, Nov 16, 2013 at 9:04 PM, Hugo Mendoza <[email protected]> wrote:

> Hi there -
>
> Here is what I receive from my db (which I think is fine):
> {"cols":[{"label":"priority","type":"string"},{"label":"num_count","type":"number"}],"rows":[{"c":[{"v":"High"},{"v":"4"}]},{"c":[{"v":"Low"},{"v":"3"}]},{"c":[{"v":"Medium"},{"v":"7"}]},{"c":[{"v":"Urgent"},{"v":"2"}]}]}
>
> But when I run this (posted below), I get the following error message: *Table
> has no columns.  *Could someone help me out?  Thank you!
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
> http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
> <html xmlns="http://www.w3.org/1999/xhtml";>
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
> <title>Sample Pie Chart</title>
>     <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">
>       google.load("visualization", "1", {packages:["corechart"]});
>       google.setOnLoadCallback(drawChart);
>       function drawChart() {
>
>       var jsonData = $.ajax({
>           url: "data-file.php",
>           dataType:"json",
>           async: false
>           }).responseText;
>
>       var data = new google.visualization.DataTable(<?php echo
> json_encode($table); ?>);
>       var chart = new
> google.visualization.PieChart(document.querySelector('#chart_div'));
>       chart.draw(data, {
>           // put the chart options in here
>           height: 800,
>           width: 600
>       });
>
>       }
>   google.load('visualization', '1', {packages: ['corechart'], callback:
> drawChart});
>
>     </script>
>
> </head>
> <body>
>
> <p>Pie Chart </p>
>     <div id="chart_div" style="width: 900px; height: 500px;"></div>
>
> </body>
> </html>
>
>
>
>
>
>
>
>
> On Saturday, November 16, 2013 5:00:15 PM UTC-5, Hugo Mendoza wrote:
>
>> Hi there -
>>
>> I figured out how to put my data into a JSON format using PHP and MySQL,
>> see below.  Now, could someone please help me create, say, a pie chart with
>> Google Charts.  I have not done this before, and I could use some help
>> creating it.
>>
>> <?php
>> // Connect to MySQL
>>
>> include ("./mylibrary/login.php");
>> login();
>>
>> // Fetch the data
>> $query = "
>>    SELECT priority, COUNT(*) AS num_count\n"
>>      . " FROM issue\n"
>>      . " GROUP BY priority ";
>>
>> $result = mysql_query( $query );
>>
>> // All good?
>> if ( !$result ) {
>> // Nope
>> $message  = 'Invalid query: ' . mysql_error() . "\n";
>> $message .= 'Whole query: ' . $query;
>> die( $message );
>> }
>>
>> // Print out rows
>> $prefix = '';
>> echo "[\n";
>> while ( $row = mysql_fetch_assoc( $result ) ) {
>> echo $prefix . " {\n";
>> echo '  "priority": "' . $row['priority'] . '",' . "\n";
>> echo '  "num_count": ' . $row['num_count'] .  "\n";
>> echo " }";
>> $prefix = ",\n";
>> }
>> echo "\n]";
>>
>> ?>
>>
>> Thank you,
>> Hugo
>>
>>  --
> 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.
>



-- 
Daniel LaLiberte <https://plus.google.com/100631381223468223275?prsrc=2>  -
978-394-1058
[email protected] <[email protected]>   5CC, Cambridge MA
[email protected] <[email protected]> 9 Juniper Ridge
Road, Acton MA

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