Ver Mensaje Individual
  #13 (permalink)  
Antiguo 29/08/2012, 21:17
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 , ya logro graficar

pero tengo un problema con el ejex donde estan las fechas , me divide en 24 fechas y la consulta solo tiene 5 registros

campo10 fechas1
real doble precision
10 1340773983
8 1340773246
5 1340773654
30 1340774539
25 1340774119


este es el codigo que utilizo

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.  
  9. $width=700; $height=400;
  10. $graph = new Graph($width, $height);
  11. $graph->SetScale('datlin');
  12. $graph->SetMargin(60,20,40,60);
  13.  
  14. $graph->title->SetFont(FF_ARIAL,FS_BOLD,12);
  15. $graph->title->Set('Development since 1984');
  16. $graph->subtitle->SetFont(FF_ARIAL,FS_ITALIC,10);
  17. $graph->subtitle->Set('(Example using the builtin date scale)');
  18.  
  19.  
  20. $graph->xaxis->SetFont(FF_ARIAL,FS_NORMAL,8);
  21. $graph->xaxis->SetLabelAngle(30);
  22.  
  23.  
  24.  
  25.                 $servidor = 'localhost';
  26.         $bd = 'tremor';
  27.         $usuario = 'postgres';
  28.         $contrasenia = '*****';
  29.         $tabla = 'tremor';
  30.        
  31.  
  32.         global $servidor, $bd, $usuario, $contrasenia;
  33.         $db = new PDO('pgsql:host=' . $servidor . ';dbname=' . $bd, $usuario, $contrasenia);
  34.  
  35.         $consulta = $db->prepare("SELECT campo10, campo1, EXTRACT(epoch FROM campo1)AS fechas1 FROM tremor;");
  36.         $consulta->execute();
  37.  
  38.         while($fila = $consulta->fetch(PDO::FETCH_ASSOC))
  39.         {
  40.         $ydata[] = $fila['campo10'];
  41.         $xdata[] = $fila['fechas1'];
  42.        
  43.         }
  44. //var_dump($xdata, $ydata);
  45.  
  46. $lp1 = new LinePlot($ydata,$xdata);
  47. $lp1->SetWeight(0);
  48. $lp1->SetFillColor('[email protected]');
  49. $graph->Add($lp1);
  50.  
  51. $lp2 = new LinePlot($ydata,$xdata);
  52. $lp2->SetColor('orange');
  53. $graph->Add($lp2);
  54.  
  55.  
  56. $graph->Stroke();


que estoy haciendo mal?

quiero mostrarle las imagenes pero no se como subirlas no tengo pagina para subirla.

Última edición por Montes28; 29/08/2012 a las 21:23