Advertisement
Guest User

Untitled

a guest
May 15th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. <?php
  2.  
  3. // JS property
  4. $label = "";
  5. // JS property
  6. $data = [];
  7.  
  8. $host = "192.168.0.29";
  9. $user = "root";
  10. $password = "";
  11. $database = "ocomon_rc6";
  12. $connection = mysqli_connect($host, $user, $password, $database);
  13. if (!$connection) {
  14. die("Connection failed: " . mysqli_connect_error());
  15. }
  16. $sql = "SELECT * FROM view_chamadosrow";
  17. $result = mysqli_query($connection, $sql);
  18. /** @noinspection PhpAssignmentInConditionInspection */
  19. while ($row = mysqli_fetch_assoc($result)) {
  20. $label = $row["TEC"];
  21. unset($row["TEC"]);
  22. $data[] = $row;
  23. }
  24. mysqli_close($connection);
  25.  
  26. ?>
  27. <!doctype html>
  28. <html>
  29.  
  30. <head>
  31. <title>Line Chart</title>
  32. <script src="dist/Chart.bundle.js"></script>
  33. <script src="utils.js"></script>
  34. <style>
  35. canvas {
  36. -moz-user-select: none;
  37. -webkit-user-select: none;
  38. -ms-user-select: none;
  39. }
  40. </style>
  41. </head>
  42.  
  43. <body>
  44. <div style="width:75%;">
  45. <canvas id="canvas"></canvas>
  46. </div>
  47. <script>
  48. var config = {
  49. type: 'line',
  50. data: {
  51. labels: ["1", "2", "3",
  52. "4", "5", "6",
  53. "7", "8", "9",
  54. "10", "11", "12",
  55. "13", "14", "15",
  56. "16", "17", "18",
  57. "19", "20", "21",
  58. "22", "23", "24",
  59. "25", "26", "27",
  60. "28", "29", "30",
  61. "31"],
  62.  
  63. datasets: [{
  64. label: "<?php echo "$label"; ?>",
  65. data: "<?php echo json_encode($data, JSON_NUMERIC_CHECK); ?>"
  66. }]
  67. },
  68.  
  69. options: {
  70. responsive: true,
  71. title: {
  72. display: true,
  73. text: 'CONTROLE DE CHAMADOS FECHADOS'
  74. },
  75. tooltips: {
  76. mode: 'index',
  77. intersect: false,
  78. },
  79. hover: {
  80. mode: 'nearest',
  81. intersect: true
  82. },
  83. scales: {
  84. xAxes: [{
  85. display: true,
  86. scaleLabel: {
  87. display: true,
  88. labelString: 'Dias'
  89. }
  90. }],
  91. yAxes: [{
  92. display: true,
  93. scaleLabel: {
  94. display: true,
  95. labelString: 'Quantidades'
  96. }
  97. }]
  98. }
  99. }
  100. };
  101.  
  102. window.onload = function () {
  103. var ctx = document.getElementById("canvas").getContext("2d");
  104. window.myLine = new Chart(ctx, config);
  105. };
  106.  
  107. </script>
  108. </body>
  109.  
  110. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement