Al fin logre entender la api de google para hacer gráficas...
El problemas es que puedo leer el array si escribo los meses de uno en uno, pero quiero hacerlo por fechas. Digamos del 2014-09-01 al 2014-31-12.
Pueden ayudarme, porfavor a mejorar el código.
Aqui esta lo que llevo.
Código HTML:
Ver original<?php
$conexion = mysqli_connect("localhost","root","root","grafica");
$meses = array('','Ene','Feb','Mar','Abr','May','Jun','Jul','Ago','Sept','Oct','Nov','Dic');
for($x=1;$x<=12;$x=$x+1){
$dinero[$x]=0;
}
$anno=date('Y');
$sql="SELECT * FROM valores";
$res=mysqli_query($conexion,$sql);
while($row=mysqli_fetch_array($res)){
$y=date("Y", strtotime($row['fecha']));
$mes=(int)date("m", strtotime($row['fecha']));
if($y==$anno){
$dinero[$mes]=$dinero[$mes]+$row['valor'];
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script type="text/javascript" src="https://www.google.com/jsapi"></script> <script type="text/javascript"> google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Mes', 'Valores'],
<?php
for($x=1;$x<=12;$x=$x+1){
?>
['<?php echo $meses[$x]; ?>', <?php echo $dinero[$x] ?>],
<?php } ?>
]);
var options = {
title: 'ESTATUS DE LA COMPAÑIA',
hAxis: {title: 'Grafica Reporte de Ingresos Anual', titleTextStyle: {color: 'red'}}
};
var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
<div id="chart_div" style="width: 98%; height: 500px;"></div>