Hi Moses,

A useful thing to do when you are not sure whether the data you are sending
to the browser is correct is to display it in a Table chart.  Make sure
your data for the PieChart is one column of strings and one column of
numbers.

On Sat, Jun 13, 2015 at 6:34 PM, moses yemi <[email protected]> wrote:

> dont know where am get it wrong, data were correctly encode to json  with
> the following php script:
>
>
> myphpscript.php
>
> <?php
>
>     $con = mysqli_connect("localhost","demo","demo","demotable") or
> die("Error " . mysqli_error($con));
>
>
>     $sql = "select id,name from training";
>     $result = mysqli_query($con, $sql) or die("Error in Selecting " .
> mysqli_error($con));
> $emparray = array();
>     $emparray['cols'] = array(
> array('label' => 'name', 'type' =>  'string'),
> array('label' => 'id', 'type' =>  'number')
> );
>  $rows = array();
> while($r = mysqli_fetch_assoc($result)) {
> $temp = array();
> $temp[] = array('v' =>  (string) $r['name']);
> $temp[] = array('v' =>  (int) $r['id']);
> $rows[] = array('c' =>  $temp);
> }
> $emparray['rows'] = $rows;
> $fp = fopen('training_data.json', 'w+');
>     fwrite($fp, json_encode($emparray,JSON_NUMERIC_CHECK));
>     fclose($fp);
> $string = file_get_contents('training_data.json');
>     echo $string;
>  mysqli_close($con);
>  ?>
>
>
>
> while my ajax script to display the pie chart is shown below:
>
>
> index.html
>
>
> <html>
>   <head>
>     <!--Load the AJAX API-->
>     <script type="text/javascript" src="https://www.google.com/jsapi
> "></script>
>     <script type="text/javascript" src="js/jquery-1.11.3.min.js"></script>
> <script type="text/javascript" src="js/jquery.browser.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() {
>     $.ajax({
>         url: "myphpscript.php",
> method: "GET",
>         dataType: "json",
>         success: function (jsonData) {
>             alert('success');
>             if (!$.browser.msie) {
>                 console.log(jsonData);
>
>             }
>
>       // 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: 900, height: 700});
>     },
> error: function(jqXHR, textStatus, errorThrown)  {
> alert(textStatus + '\n' + errorThrown);
> if(!$.browser.msie){
> console.log(jqXHR);
> }
>    }
> });
> }
>     </script>
>   </head>
>
>   <body>
>     <!--Div that will hold the pie chart-->
>     <div id="chart_div"></div>
>   </body>
> </html>
>
>
> and the result i get is display as shown in the attached.
>
> increased the max_memory_limit of my wampserver: to 512M still the same.
>
> Kindly help.
>
>  --
> 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/d/optout.
>



-- 
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/d/optout.

Reply via email to