Hello,
I'm new to Google Charts & want to make a combo chart. 
I have fired a query & want the output to be shown in ComboChart Format. 
Here is the code i have tried

<?php
$con=mysqli_connect("localhost","root","") or die("Failed to connect with 
database!!!!");
mysqli_select_db($con,"tdata");
$sth = mysqli_query($con,"SET @cust_rank   := NULL;SET @current_cust:= NULL;
SELECT site,item_code,customer_name,item_value,cust_rank FROM (SELECT 
b.site,b.item_code,b.customer_name,b.item_value, @cust_rank := 

IF(@current_cust=a.customer_name ,@cust_rank+1,1) AS 
cust_rank,@current_cust:=a.customer_name FROM(SELECT site,customer_name,SUM

(item_amount) Total_value FROM `cmpslsalesdata` WHERE site='BDD1' GROUP BY 
site,customer_name ORDER BY Total_value DESC limit 5) a,

(SELECT site,item_code,customer_name,SUM(item_amount) AS item_value FROM 
`cmpslsalesdata` WHERE site='BDD1' GROUP BY 

site,item_code,customer_name ORDER BY customer_name,item_code,item_value 
DESC) b WHERE a.customer_name=b.customer_name) c WHERE 

c.cust_rank <=10 ORDER BY customer_name,item_code");
 
$rows = array();
//flag is not needed
$flag = true;
$table = array();
$table['cols'] = array(
 
    // Labels for your chart, these represent the column titles
    // Note that one column is in "string" format and another one is in 
"number" format as pie chart only required "numbers" for 

calculating percentage and string will be used for column title
    array('label' => 'Customer_name', 'type' => 'string'),
    array('label' => 'Total_Amount', 'type' => 'number')
);
 
$rows = array();
while($r = mysqli_fetch_assoc($sth)) {
    $temp = array();
    // the following line will be used to slice the Pie chart
    $temp[] = array('v' => (string) $r['Customer_name']); 
    // Values of each slice
    $temp[] = array('v' => (float) $r['Total_Amount']);
    $rows[] = array('c' => $temp);
}
$table['rows'] = $rows;
$jsonTable = json_encode($table);
//echo $jsonTable;
?>
<html>
  <head>
    <!--Load the Ajax API-->
    <script type="text/javascript" 
src="https://www.google.com/jsapi";></script>
    <script type="text/javascript" 
src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.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() {
 
      // Create our data table out of JSON data loaded from server.
      var data = new google.visualization.DataTable(<?=$jsonTable?>);
      var options = {
           title: ' Report  (BDD1) ',
          is3D: 'true',
hAxis: {
          title: 'Top Customers'
        },
        vAxis: {
          title: 'Sales in Rs.'
        },
          width: 600,
          height: 500
        };
      // Instantiate and draw our chart, passing in some options.
      // Do not forget to check your div ID
      var chart = new 
google.visualization.ComboChart(document.getElementById('BDD1SALES'));
      chart.draw(data, options);
    }
    </script>
  </head>
  <body>
<!--this is the div that will hold the pie chart-->
<div id="BDD1SALES" align="center"></div>
</body>
</html>

I'm getting error of  Warning: mysqli_fetch_assoc() expects parameter 1 to 
be mysqli_result, boolean on line 21


*Please Help ! *
*Thanks 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-visualization-api/5d31de7a-2684-42cf-b06f-dd10f99d9d16%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to