Ver Mensaje Individual
  #19 (permalink)  
Antiguo 30/08/2012, 19:46
Montes28
 
Fecha de Ingreso: septiembre-2010
Mensajes: 1.853
Antigüedad: 13 años, 7 meses
Puntos: 6
Respuesta: Problema con jpgraph y postgresql

Triby gracias por responder , pero donde pueden estar esas etiquetas


te voy a mostrar como esta construido el ejemplo

Código PHP:
Ver original
  1. include('inc/jpgraph.php');
  2. include('inc/jpgraph_line.php');
  3. include('inc/jpgraph_date.php');
  4. include('inc/jpgraph_utils.inc.php');
  5.  
  6. // Get a dataset stored in $xdata and $ydata
  7. include('inc/dataset01.inc.php');
  8.  
  9. $dateUtils = new DateScaleUtils();
  10.  
  11. // Setup a basic graph
  12. $width=700; $height=400;
  13. $graph = new Graph($width, $height);
  14. $graph->SetScale('datlin');
  15. $graph->SetMargin(60,20,40,60);
  16.  
  17. // Setup the titles
  18. $graph->title->SetFont(FF_ARIAL,FS_BOLD,12);
  19. $graph->title->Set('Development since 1984');
  20. $graph->subtitle->SetFont(FF_ARIAL,FS_ITALIC,10);
  21. $graph->subtitle->Set('(Example using the builtin date scale)');
  22.  
  23. // Setup the labels to be correctly format on the X-axis
  24. $graph->xaxis->SetFont(FF_ARIAL,FS_NORMAL,8);
  25. $graph->xaxis->SetLabelAngle(30);
  26.  
  27. $lp1 = new LinePlot($ydata,$xdata);
  28. $lp1->SetWeight(0);
  29. $lp1->SetFillColor('[email protected]');
  30. $graph->Add($lp1);
  31.  
  32. // And then add line. We use two plots in order to get a
  33. // more distinct border on the graph
  34. $lp2 = new LinePlot($ydata,$xdata);
  35. $lp2->SetColor('orange');
  36. $graph->Add($lp2);
  37.  
  38. // And send back to the client
  39. $graph->Stroke();

include('inc/dataset01.inc.php')

en dataset01.inc.php estan los datos almacenados




Código PHP:
Ver original
  1. $ydata = array(
  2.     0 => 1.0885908919277, 1 =>
  3.     0.99034385297982, 2 => 0.97005467188578, 3 =>
  4.     0.99901201350824, 4 => 1.1263167971152, 5 =>
  5.     1.0582808133448, 6 => 1.0216740689064, 7 =>
  6.     0.96626236356644, 8 => 1.0125912828768, 9 =>
  7.  
  8. $xdata = array(
  9.  
  10.     0 => 444348000, 1 => 446853600, 2 =>
  11.     449532000, 3 => 452124000, 4 => 454802400, 5 =>
  12.     457394400, 6 => 460072800, 7 => 462751200, 8 =>


lo unico que yo estoy cambiando es de donde consigo los datos

a continuacion mi codigo


Código PHP:
Ver original
  1. include('inc/jpgraph.php');
  2. include('inc/jpgraph_line.php');
  3. include('inc/jpgraph_date.php');
  4. include('inc/jpgraph_utils.inc.php');
  5.  
  6. $dateUtils = new DateScaleUtils();
  7.  
  8. $width=700; $height=400;
  9. $graph = new Graph($width, $height);
  10. $graph->SetScale('datlin');
  11. $graph->SetMargin(60,20,40,60);
  12.  
  13. $graph->title->SetFont(FF_ARIAL,FS_BOLD,12);
  14. $graph->title->Set('Development since 1984');
  15. $graph->subtitle->SetFont(FF_ARIAL,FS_ITALIC,10);
  16. $graph->subtitle->Set('(Example using the builtin date scale)');
  17.  
  18. $graph->xaxis->SetFont(FF_ARIAL,FS_NORMAL,8);
  19. $graph->xaxis->SetLabelAngle(30);
  20.  
  21. $servidor = 'localhost';
  22.         $bd = 'tremor';
  23.         $usuario = 'postgres';
  24.         $contrasenia = 'hoe798cs';
  25.         $tabla = 'tremor';
  26.        
  27.  
  28.         global $servidor, $bd, $usuario, $contrasenia;
  29.         $db = new PDO('pgsql:host=' . $servidor . ';dbname=' . $bd, $usuario, $contrasenia);
  30.  
  31.         $consulta = $db->prepare("SELECT campo10, campo1, EXTRACT(epoch FROM campo1)AS fechas1 FROM tremor;");
  32.         $consulta->execute();
  33.  
  34.         while($fila = $consulta->fetch(PDO::FETCH_ASSOC))
  35.         {
  36.               $ydata[] = $fila['campo10'];
  37.                   $xdata[] = $fila['fechas1'];
  38.                  }
  39.  
  40. $lp1 = new LinePlot($ydata,$xdata);
  41. $lp1->SetWeight(0);
  42. $lp1->SetFillColor('[email protected]');
  43. $graph->Add($lp1);
  44.  
  45. $lp2 = new LinePlot($ydata,$xdata);
  46. $lp2->SetColor('orange');
  47. $graph->Add($lp2);
  48.  
  49. $graph->Stroke();


que estoy haciendo mal?