Ver Mensaje Individual
  #3 (permalink)  
Antiguo 14/03/2013, 16:24
DM270
 
Fecha de Ingreso: octubre-2012
Mensajes: 7
Antigüedad: 12 años, 5 meses
Puntos: 0
Respuesta: Generar gráficos con PHP desde BD

Con datos fijos funciona correctamente, el problema es que no me muestra nada.
lo pongo nuevamente:

Así hago conexión a la base de datos.
Código PHP:
Ver original
  1. <?
  2.     $link = mysql_connect('localhost', 'user', 'password');
  3.     @mysql_database("indicadores",$link);
  4.     if (!$link) {
  5.         die('Error de Conexión' . mysql_error());
  6.                 }
  7.     echo 'Conexión Correcta';
  8. ?>

Ahora esa conexión la llamo al archivo php en el cual quiero generar la gráfica:
Y es en la cual en la que no sé si estoy haciendolo bien!
Código PHP:
Ver original
  1. <?php
  2. include      ("consulta2.php");//Este php es donde estoy llamando la conexión
  3. include_once ("jpgraph.php");
  4. include_once ("jpgraph_bar.php");
  5.  
  6. $query = mysql_query("SELECT nombre,producido FROM aa1");
  7.  
  8.     while($row = mysql_fetch_array($query))
  9.     {
  10.      $data[] = $row[0];
  11.      $can[] = $row[1];
  12.     }
  13.  
  14. // Create the graph.
  15. // One minute timeout for the cached image
  16. // INLINE_NO means don't stream it back to the browser.
  17. $graph = new Graph(310,250,'auto');
  18. $graph->SetScale("textlin");
  19. $graph->img->SetMargin(60,30,20,40);
  20. $graph->yaxis->SetTitleMargin(45);
  21. $graph->yaxis->scale->SetGrace(30);
  22. $graph->SetShadow();
  23.  
  24. // Turn the tickmarks
  25. $graph->xaxis->SetTickSide(SIDE_DOWN);
  26. $graph->yaxis->SetTickSide(SIDE_LEFT);
  27.  
  28. // Create a bar pot
  29. $bplot = new BarPlot($can);
  30.  
  31. // Create targets for the image maps. One for each column
  32. $targ=array("bar_clsmex1.php#1","bar_clsmex1.php#2","bar_clsmex1.php#3","bar_clsmex1.php#4","bar_clsmex1.php#5","bar_clsmex1.php#6");
  33. $alts=array("val=%d","val=%d","val=%d","val=%d","val=%d","val=%d");
  34. $bplot->SetCSIMTargets($targ,$alts);
  35. $bplot->SetFillColor("orange");
  36.  
  37. // Use a shadow on the bar graphs (just use the default settings)
  38. $bplot->SetShadow();
  39. $bplot->value->SetFormat(" $ %2.1f",70);
  40. $bplot->value->SetFont(FF_ARIAL,FS_NORMAL,9);
  41. $bplot->value->SetColor("blue");
  42. $bplot->value->Show();
  43.  
  44. $graph->Add($bplot);
  45.  
  46. $graph->title->Set("Línea AA1, 2, 9, E3");
  47. $graph->xaxis->title->Set("Supervisor");
  48. $graph->yaxis->title->Set("Objetivo");
  49.  
  50. $graph->title->SetFont(FF_FONT1,FS_BOLD);
  51. $graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
  52. $graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
  53.  
  54. // Send back the HTML page which will call this script again
  55. // to retrieve the image.
  56. $graph->StrokeCSIM();
  57. ?>
Espero puedas ayudarme!