Last active
May 15, 2017 19:39
-
-
Save wilcorrea/797500f5fed2f8e27bd8a6cf0c6d1e68 to your computer and use it in GitHub Desktop.
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 | |
// JS property | |
$data = []; | |
$host = "192.168.0.29"; | |
$user = "root"; | |
$password = ""; | |
$database = "ocomon_rc6"; | |
$connection = mysqli_connect($host, $user, $password, $database); | |
if (!$connection) { | |
die("Connection failed: " . mysqli_connect_error()); | |
} | |
$sql = "SELECT * FROM view_chamadosrow"; | |
$result = mysqli_query($connection, $sql); | |
/** @noinspection PhpAssignmentInConditionInspection */ | |
while ($row = mysqli_fetch_assoc($result)) { | |
$label = utf8_encode($row["TEC"]); | |
unset($row["TEC"]); | |
$data[] = [ | |
'label' => $label, | |
'data' => array_values($row) | |
]; | |
} | |
mysqli_close($connection); | |
?> | |
<!doctype html> | |
<html> | |
<head> | |
<title>Line Chart</title> | |
<script src="dist/Chart.bundle.js"></script> | |
<script src="utils.js"></script> | |
<style> | |
canvas { | |
-moz-user-select: none; | |
-webkit-user-select: none; | |
-ms-user-select: none; | |
} | |
</style> | |
</head> | |
<body> | |
<div style="width:75%;"> | |
<canvas id="canvas"></canvas> | |
</div> | |
<script> | |
var config = { | |
type: 'line', | |
data: { | |
labels: ["1", "2", "3", | |
"4", "5", "6", | |
"7", "8", "9", | |
"10", "11", "12", | |
"13", "14", "15", | |
"16", "17", "18", | |
"19", "20", "21", | |
"22", "23", "24", | |
"25", "26", "27", | |
"28", "29", "30", | |
"31"], | |
datasets: <?php echo json_encode($data, JSON_NUMERIC_CHECK); ?> | |
}, | |
options: { | |
responsive: true, | |
title: { | |
display: true, | |
text: 'CONTROLE DE CHAMADOS FECHADOS' | |
}, | |
tooltips: { | |
mode: 'index', | |
intersect: false, | |
}, | |
hover: { | |
mode: 'nearest', | |
intersect: true | |
}, | |
scales: { | |
xAxes: [{ | |
display: true, | |
scaleLabel: { | |
display: true, | |
labelString: 'Dias' | |
} | |
}], | |
yAxes: [{ | |
display: true, | |
scaleLabel: { | |
display: true, | |
labelString: 'Quantidades' | |
} | |
}] | |
} | |
} | |
}; | |
window.onload = function () { | |
var ctx = document.getElementById("canvas").getContext("2d"); | |
window.myLine = new Chart(ctx, config); | |
}; | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment