php - Display Vertical bar chart with grouped bars. -


i trying create barchart using google charts. want display both sales orders , sales quotations total value each month. have done this, displays orders value each month in horizontal format. not getting how show both values using single barchart (vertically)

here code

$query = "select monthname(last_modified) month,                   orders.sales_order_id,                   orders.authorise, orders.company_id,                  before_order_line_items.sales_order_id,                  before_order_line_items.item,                  before_order_line_items.uom,                   sum(before_order_line_items.total) 'total',                  before_order_line_items.tax orders inner join                    before_order_line_items on                  orders.sales_order_id on                      before_order_line_items.sales_order_id              orders.order_quote = 'order'             , orders.authorise='yes'             group month(orders.last_modified)             order month(orders.last_modified)";   $result = mysqli_query($con, $query);   while ($row = mysqli_fetch_array($result))     {       $myurl[] = "['".$row['month']."', ".$row['total']."]";      }  <script type="text/javascript">       google.load("visualization", "1", {packages:["corechart"]});       google.setonloadcallback(drawchart);       function drawchart() {          var data = google.visualization.arraytodatatable([           ['month', 'actuals'],          /* ['2004',  1000,      400],           ['2005',  1170,      460],           ['2006',  660,       1120],           ['2007',  1030,      540]*/               <?php echo implode(",", $myurl);               ?>          ]);          var options = {           title: 'orders',           vaxis: {title: '',  titletextstyle: {color: 'red'}}         };          var chart = new google.visualization.barchart(document.getelementbyid('chart_div'));         chart.draw(data, options);       }     </script> 

first, need adjust sql return both values

then add columns $myurl[]

$myurl[] = "['".$row['month']."', ".$row['quotes'].", ".$row['orders']."]";

from there, draw chart, recommend using loader.js vs. older library jsapi

something should close...

$query = "select             monthname(last_modified) month,             sum(case when orders.order_quote = 'order' before_order_line_items.total else 0 end) orders,             sum(case when orders.order_quote = 'quote' before_order_line_items.total else 0 end) quotes           orders           inner join before_order_line_items           on orders.sales_order_id = before_order_line_items.sales_order_id           orders.authorise = 'yes'           group month(orders.last_modified)           order month(orders.last_modified)";  $result = mysqli_query($con, $query); while ($row = mysqli_fetch_array($result)) {   $myurl[] = "['".$row['month']."', ".$row['quotes'].", ".$row['orders']."]"; }  <script src="https://www.gstatic.com/charts/loader.js"></script> <script type="text/javascript">   google.charts.load('current', {     callback: drawchart,     packages: ['corechart']   });    function drawchart() {     var data = google.visualization.arraytodatatable([       ['month', 'quotes', 'orders'],       <?php         echo implode(",", $myurl);       ?>     ]);      var options = {       title: 'orders',       vaxis: {         title: '',         titletextstyle: {           color: 'red'         }       }     };      var chart = new google.visualization.columnchart(document.getelementbyid('chart_div'));     chart.draw(data, options);   } </script> 

Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -