Hi there,
Not really a Script shark yet. PHP is more my game..
I want to show a google bar chart from a mysqli database.
Here is my code..:
<?PHP
include "config.php";
for($i=0; $i<=6; $i++){
$dato=date('Y-m-d',strtotime("-".$i." days"));
$hent=mysqli_query($con,"SELECT * FROM WithdrawalLog WHERE tid LIKE
'%".$dato."%' AND Location='Location1' ORDER BY id DESC LIMIT 0, 1000");
while($row=mysqli_fetch_array($hent)){
$amount=abs($row["antalLiter"]);
$loction1=$location1+$amount;
}
$hent=mysqli_query($con,"SELECT * FROM WithdrawalLog WHERE tid LIKE
'%".$dato."%' AND Location='Location2' ORDER BY id DESC LIMIT 0, 1000");
while($row=mysqli_fetch_array($hent)){
$amount=abs($row["antalLiter"]);
$location1=$location1+$amount;
}
$resultat .= "['".$dato."', '".$location1."','".$location2."'],";
$location1=0;
$location2=0;
}
?>
<html>
<head>
<script type="text/javascript"
src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {'packages':['bar']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Dato', 'Location1', 'Location2'],
<?PHP
echo $resultat;
?>
]);
var options = {
chart: {
title: 'Last 7 days',
subtitle: 'Date and location',
}
};
var chart = new
google.charts.Bar(document.getElementById('columnchart_material'));
chart.draw(data, google.charts.Bar.convertOptions(options));
}
</script>
<meta http-equiv="refresh" content="60" >
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div id="columnchart_material" style="width: 90%; margin:auto; height:
500px;"></div>
</body>
</html>
Here is how the chart is processed..
<https://lh3.googleusercontent.com/-XluKSMt_pls/WcOJe070QGI/AAAAAAAAAAM/T50rdnJ_Q2cDh_SN5jp6GubE8eItweomQCLcBGAs/s1600/Udklip.PNG>
My problem is that the chart seems to show the first 2 entrys as negative
numbers although they are positive. (when i mouseover the column it even
shows a positive number).
How can i alter this in the code to get a correct vertical left side scale ?
--
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 https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-visualization-api/5633a9a9-0a4d-4eea-8bcd-dcdacb91bc1e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.