Guest User

Untitled

a guest
Mar 9th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. <?php
  2.  
  3. $mes = array();
  4. $total = array();
  5. $cor = array();
  6. $cor[0] = '#ff3300';
  7. $cor[1] = '#0000ff';
  8. $cor[2] = '#006600';
  9. $i = 0;
  10.  
  11.  
  12. $servername = "xxx.xxx.x.xx";
  13. $username = "xxxxx";
  14. $password = "xxxxxxx";
  15. $dbname = "xxxxxxx";
  16.  
  17. $conn = new mysqli($servername, $username, $password, $dbname);
  18. $conn->set_charset('utf8');
  19.  
  20. $sql = "SELECT MONTH(centrodb.registosagudizacoes.Dataregresso) AS Mes,
  21. COUNT(NomeUtente) AS Total
  22.  
  23. FROM centrodb.registosagudizacoes LEFT OUTER JOIN centrodb.ChegAgudizacoes
  24.  
  25. on centrodb.ChegAgudizacoes.NumRegisto = centrodb.registosagudizacoes.id
  26.  
  27. WHERE centrodb.registosagudizacoes.Dataregresso IS NOT NULL
  28.  
  29. GROUP BY MONTH(centrodb.registosagudizacoes.Dataregresso);";
  30.  
  31. $resultado_cursos = mysqli_query($conn, $result_cursos);
  32.  
  33. while($rows_cursos = mysqli_fetch_object($resultado_cursos)) {
  34.  
  35. $meses = $rows_cursos->Mes;
  36. $totais = $rows_cursos->Total;
  37. $mes[$i] = $meses;
  38. $total[$i] = $total;
  39. $i = $i + 1;
  40. }
  41.  
  42. ?>
  43.  
  44. <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
  45. <script type="text/javascript">
  46. google.charts.load("current", {packages:['corechart']});
  47. google.charts.setOnLoadCallback(drawChart);
  48. function drawChart() {
  49. var data = google.visualization.arrayToDataTable([
  50. ["Mês", "Total", { role: "style" } ],
  51. <?php
  52. $k = $i;
  53. for ($i = 0; $i < $k; $i++) {
  54. ?>
  55. ['<?php echo $mes[$i] ?>', <?php echo $total[$i] ?>, '<?php echo $cor[$i] ?>' ],
  56. <?php } ?>
  57. ]);
  58.  
  59. var view = new google.visualization.DataView(data);
  60. view.setColumns([0, 1,
  61. { calc: "stringify",
  62. sourceColumn: 1,
  63. type: "string",
  64. role: "annotation" },
  65. 2]);
  66.  
  67. var options = {
  68. title: "Density of Precious Metals, in g/cm^3",
  69. width: 600,
  70. height: 400,
  71. bar: {groupWidth: "95%"},
  72. legend: { position: "none" },
  73. };
  74. var chart = new google.visualization.ColumnChart(document.getElementById("columnchart_values"));
  75. chart.draw(view, options);
  76. }
  77. </script>
  78. <div id="columnchart_values" style="width: 900px; height: 300px;"></div>
  79.  
  80. **Data column(s) for axis #0 cannot be of type string×**
Add Comment
Please, Sign In to add comment