Well folks I have a query of the Bank that returns an array of data. and wanted to put the values to be displayed in the graph in Bars. I tried this but with values coming from vector the graph does not load.
while ($estoque = $estoques->fetch_assoc()) {?>
<?$semana[$i]=$estoque['week'];
$valor[$i]=$estoque['quant'];
);
}
$i=$semana[$i];
print"<script>alert('$i')</script>";
?>
<canvas id="GraficoBarra" style="width:50%;"></canvas>
<script type="text/javascript">
var options = {
responsive:true
};
var data = {
labels: [<?print $semana[1];?>, <?print $semana[2];?>,<?print $semana[3];?>, <?print $semana[4];?>, <?print $semana[5];?>, <?print $semana[6];?>, <?print $semana[7];?>, <?print $semana[8];?>],
datasets: [
{
label: "Dados secundários",
fillColor: "rgba(151,187,205,0.5)",
strokeColor: "rgba(151,187,205,0.8)",
highlightFill: "rgba(151,187,205,0.75)",
highlightStroke: "rgba(151,187,205,1)",
labels: [<?print $valor[1];?>, <?print $valor[2];?>,<?print $valor[3];?>, <?print $valor[4];?>, <?print $valor[5];?>, <?print $valor[6];?>, <?print $valor[7];?>, <?print $valor[8];?>]
}
]
};
window.onload = function(){
var ctx = document.getElementById("GraficoBarra").getContext("2d");
var BarChart = new Chart(ctx).Bar(data, options);
}
</script>