Ver Mensaje Individual
  #4 (permalink)  
Antiguo 12/05/2011, 16:07
mixzplit
 
Fecha de Ingreso: enero-2011
Ubicación: Maracaibo
Mensajes: 179
Antigüedad: 13 años, 3 meses
Puntos: 2
Respuesta: Cómo hacer gráficas con jpgraph y mysql

Hola omar_gutierrez, te pongo un script que yo uso donde trabajo jpgraph con base de datos (mysql) donde te graficara dependiendo de lo que trengas en la base de datos, espero te sirva

Código PHP:
Ver original
  1. <?php
  2.     include("conex.php");
  3.     include("jpgraph/src/jpgraph.php");
  4.     include("jpgraph/src/jpgraph_pie.php");
  5.     include("jpgraph/src/jpgraph_pie3d.php");
  6.    
  7.     $query = mysql_query("SELECT votos,candidato FROM encuesta");
  8.    
  9.     while($row = mysql_fetch_array($query))
  10.     {
  11.      $data[] = $row[0];
  12.      $can[] = $row[1];
  13.     }
  14.        
  15.     $graph = new PieGraph(550,300,"auto");
  16.     $graph->img->SetAntiAliasing();
  17.     $graph->SetMarginColor('gray');
  18. //$graph->SetShadow();
  19.  
  20. // Setup margin and titles
  21.     $graph->title->Set("Candidatos y Votos");
  22.  
  23.     $p1 = new PiePlot3D($data);
  24.     $p1->SetSize(0.45);
  25.     $p1->SetCenter(0.4);
  26.  
  27. // Setup slice labels and move them into the plot
  28.     $p1->value->SetFont(FF_FONT1,FS_BOLD);
  29.     $p1->value->SetColor("black");
  30.     $p1->SetLabelPos(0.5);
  31.  
  32.     $p1->SetLegends($can);
  33.     $p1->ExplodeAll();
  34.  
  35.     $graph->Add($p1);
  36.     $graph->Stroke();
  37.   ?>

Saludos