Created
September 15, 2016 15:57
-
-
Save JRGGRoberto/ee12cc68cecb18ac47e4fb7c466eff82 to your computer and use it in GitHub Desktop.
Google Grafs- https://google-developers.appspot.com/chart/interactive/docs/gallery/areachart#loading
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$conn = new mysqli("localhost","root","20gmtel14","Dashboards"); | |
if ($conn->connect_error) { | |
die("Connection failed: " . $conn->connect_error); | |
} | |
$sql= "select DATE_FORMAT(dt, '%k:%i') as dt, n1, n2, n3, n4, n5, n6, n51, n52 from graf_log_trunks_sft order by id"; | |
$result = $conn->query($sql); | |
if ($result->num_rows > 0) { | |
$dados = "[['dt', 'n1', 'n2', 'n3', 'n4', 'n5', 'n6', 'n51', 'n52']"; | |
while($row = $result->fetch_assoc()){ | |
$dados .= ",[ '". $row["dt"] ."',". $row["n1"] . "," . $row["n2"] . "," . $row["n3"] . "," . $row["n4"] . "," . $row["n5"] . "," . $row["n6"] . "," . $row["n51"] . "," . $row["n52"] ." ]"; | |
} | |
$dados .= "]"; | |
$result->close(); | |
}else{ | |
printf("Error"); | |
} | |
$conn->close(); | |
?> | |
<html> | |
<head> | |
<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(drawChart); | |
function drawChart() { | |
var data = google.visualization.arrayToDataTable( | |
<?php echo $dados; ?> | |
); | |
var options = { | |
title: 'Log Trunks SFR', | |
hAxis: {title: 'DtH', titleTextStyle: {color: '#333'}}, | |
vAxis: {minValue: 0} | |
}; | |
var chart = new google.visualization.AreaChart(document.getElementById('chart_div')); | |
chart.draw(data, options); | |
} | |
</script> | |
</head> | |
<body> | |
<div id="chart_div" style="width: 100%; height: 500px;"></div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment