<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawVisualization);
function drawVisualization() {
var data = google.visualization.arrayToDataTable([
['Username', 'Total Sales'],
<?php
while($sub_row = mysqli_fetch_array($result2))
{
echo "['".$sub_row["date"]."', ".$sub_row["number"]."],";
}
?>
]);
var options = {
title : 'Month & Yearly Total Sales Values',
vAxis: {title: 'Total Sales'},
hAxis: {title: 'Month & Year'},
seriesType: 'bars',
series: {5: {type: 'line'}}
};
var chart = new google.visualization.ComboChart(document.getElementById('Salesman'));
chart.draw(data, options);
}
</script>
<?php
$con = mysqli_connect('localhost','handsmec_sales','handsmec_sales','handsmec_sales_portal') or die(mysqli_error());
$query2 = "SELECT DATE_FORMAT(order_datetime,'%Y') as date, SUM(order_total_after_tax) as number FROM tbl_order where status='Confirmed' and type='PROFORMA INVOICE' GROUP BY DATE_FORMAT(order_datetime,'%Y')";
$result2 = mysqli_query($con, $query2);
?>
<div id="Salesman" style="width: 650px; height: 500px;"></div>
结果将显示为附加图像 我需要成为条形图的代码结果将根据年份不同颜色,我尝试着色:青色,红色代码,但它会反映任何解决方案的第一种颜色??
郎朗坤
开心每一天1111
红颜莎娜