4
Good afternoon, I have the following appointment:
SELECT
DATE(o.data_fechamento) AS Data,
u.nome AS Pessoa,
COUNT(*) AS Total
FROM
ocorrencias AS o
LEFT JOIN sistemas AS a ON a.sis_id = o.sistema
LEFT JOIN localizacao AS l ON l.loc_id = o.local
LEFT JOIN instituicao AS i ON i.inst_cod = o.instituicao
LEFT JOIN usuarios AS u ON u.user_id = o.operador
LEFT JOIN usuarios AS ua ON ua.user_id = o.aberto_por
LEFT JOIN `status` AS s ON s.stat_id = o.status
LEFT JOIN status_categ AS stc ON stc.stc_cod = s.stat_cat
LEFT JOIN problemas AS p ON p.prob_id = o.problema
LEFT JOIN sla_solucao AS sls ON sls.slas_cod = p.prob_sla
LEFT JOIN prioridades AS pr ON pr.prior_cod = l.loc_prior
LEFT JOIN sla_solucao AS slr ON slr.slas_cod = pr.prior_sla
LEFT JOIN script_solution AS sol ON sol.script_cod = o.oco_script_sol
LEFT JOIN prior_atend AS prioridade_atendimento ON prioridade_atendimento.pr_cod = o.oco_prior
WHERE
o.status IN (4)
AND MONTH( o.data_fechamento) = MONTH(NOW())
AND YEAR( o.data_fechamento) = YEAR(NOW())
GROUP BY DATE(o.data_fechamento),u.nome
ORDER BY o.data_fechamento ASC
It returns something like:
Data Pessoa Total
2017-04-01 MARCOS 3
2017-04-01 PAULO 5
2017-04-02 MARCOS 7
2017-04-02 PAULO 3
2017-04-03 MARCOS 8
2017-04-03 PAULO 9
2017-04-04 MARCOS 4
2017-04-04 PAULO 10
I would like to apply it with the returns automatically in a while php showing the result as the example of the image I attached below in a google line Chart.
How could I be doing this process ?
Obs: I tried it this way, but the graph is coming out empty:
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {'packages':['line']});
google.charts.setOnLoadCallback(ChamadosPorTec);
function ChamadosPorTec() {
var data = new google.visualization.DataTable();
<?php while ($row = mysql_fetch_array($QueryChamadosDiarios)){
$VarPessoa = $row['Pessoa'];
$VarTotal = $row['Total'];
$VarDia = $row['Data'];
?>
data.addColumn('number', 'DIA');
data.addColumn('number', '<?php echo $VarPessoa;?>');
data.addRows([
[ <?php echo $VarDia;?>,<?php echo $VarTotal;?>]
<?php } ?>
]);
var options = {
chart: {
title: 'CHAMADOS POR TECNICO',
subtitle: 'MÊS: <?php echo $mes_extenso["$mes"];?>'
},
width: 900,
height: 500
};
var chart = new google.charts.Line(document.getElementById('ChamadosPorTec'));
chart.draw(data, options);
}
</script>
<div class="panel panel-default">
<div class="panel-body">
<div id="ChamadosPorTec" style="width: 900px; height: 500px"></div>
</div>
</div>
What’s in your variable
$QueryChamadosDiarios
?– Taisbevalle
The query is at the beginning of the question and the result is also: 2017-04-01 MARK 3
– Chefe Druida
Have you tried using
google.visualization.arrayToDataTable
in place ofgoogle.visualization.DataTable
?– Taisbevalle
Yeah, I didn’t either :(
– Chefe Druida
When you use
google.visualization.arrayToDataTable
the mounting of the data is a little different. Look at this example. If it helps you I detain the answer– Taisbevalle
I took a look yes, I think it can work, could detail please ?
– Chefe Druida