0
I’m creating a Chart with php mysql, but the same is not returning anything on the screen.
Queries are working normally in mysql.
<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(drawVisualization);
function drawVisualization() {
var data = new google.visualization.DataTable();
data.addColumn('date', 'DATA');
data.addColumn('string', 'VENDAS');
data.addColumn('string', 'METAS');
data.addRows([
<?php
$metas = mysql_query("SELECT
i.imp_data AS DATA,
m.mt_mes AS MES,
m.mt_ano AS ANO,
FORMAT(m.mt_valor,2,'de_DE') AS META_TOTAL,
FORMAT(m.mt_valor / CAST(day(LAST_DAY(now())) as decimal),2,'de_DE') AS META_DIARIA,
FORMAT(SUM(i.imp_venda),2,'de_DE') AS VENDA
FROM metas AS m
LEFT JOIN importacao AS i ON m.mt_loja = i.imp_loja
WHERE m.mt_loja = 1
GROUP BY i.imp_data,i.imp_loja");
while ($r = mysql_fetch_array($metas)) {
echo "['$r[0]', '$r[3]]', '$r[5]]', \n";
}
?>
]);
var options = {
title : 'VENDAS ACUMULADAS',
vAxis: {title: 'PERCENTUAL'},
hAxis: {title: 'DIAS'},
seriesType: 'bars',
series: {2: {type: 'line'}}
};
var chart = new google.visualization.ComboChart(document.getElementById('vendas_diarias'));
chart.draw(data, options);
}
Check what comes on your date, use console.log(date)
– Taisbevalle