Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $mes = array();
- $total = array();
- $cor = array();
- $cor[0] = '#ff3300';
- $cor[1] = '#0000ff';
- $cor[2] = '#006600';
- $i = 0;
- $servername = "xxx.xxx.x.xx";
- $username = "xxxxx";
- $password = "xxxxxxx";
- $dbname = "xxxxxxx";
- $conn = new mysqli($servername, $username, $password, $dbname);
- $conn->set_charset('utf8');
- $sql = "SELECT MONTH(centrodb.registosagudizacoes.Dataregresso) AS Mes,
- COUNT(NomeUtente) AS Total
- FROM centrodb.registosagudizacoes LEFT OUTER JOIN centrodb.ChegAgudizacoes
- on centrodb.ChegAgudizacoes.NumRegisto = centrodb.registosagudizacoes.id
- WHERE centrodb.registosagudizacoes.Dataregresso IS NOT NULL
- GROUP BY MONTH(centrodb.registosagudizacoes.Dataregresso);";
- $resultado_cursos = mysqli_query($conn, $result_cursos);
- while($rows_cursos = mysqli_fetch_object($resultado_cursos)) {
- $meses = $rows_cursos->Mes;
- $totais = $rows_cursos->Total;
- $mes[$i] = $meses;
- $total[$i] = $total;
- $i = $i + 1;
- }
- ?>
- <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([
- ["Mês", "Total", { role: "style" } ],
- <?php
- $k = $i;
- for ($i = 0; $i < $k; $i++) {
- ?>
- ['<?php echo $mes[$i] ?>', <?php echo $total[$i] ?>, '<?php echo $cor[$i] ?>' ],
- <?php } ?>
- ]);
- var view = new google.visualization.DataView(data);
- view.setColumns([0, 1,
- { calc: "stringify",
- sourceColumn: 1,
- type: "string",
- role: "annotation" },
- 2]);
- var options = {
- title: "Density of Precious Metals, in g/cm^3",
- width: 600,
- height: 400,
- bar: {groupWidth: "95%"},
- legend: { position: "none" },
- };
- var chart = new google.visualization.ColumnChart(document.getElementById("columnchart_values"));
- chart.draw(view, options);
- }
- </script>
- <div id="columnchart_values" style="width: 900px; height: 300px;"></div>
- **Data column(s) for axis #0 cannot be of type string×**
Add Comment
Please, Sign In to add comment