18/09/2008, 04:25
|
| | Fecha de Ingreso: febrero-2006
Mensajes: 297
Antigüedad: 18 años, 2 meses Puntos: 1 | |
Respuesta: graficos tiempo dinero Código PHP: <? function renombrarfecha($fecha){ $partes=explode("-",$fecha); return ($partes[2]."/".$partes[1]."/".substr($partes[0],-2)); } include ("jpgraph/jpgraph.php"); include ("jpgraph/jpgraph_line.php"); if (!isset($_GET["lang"])) $_GET["lang"]="es"; // Datos de los precios $ydata = array(); //fechas $datax=array(); $ydata[]=""; $datax[]=""; //Relleno los arrays con los valores de la base de datos $producto=mysql_fetch_array(mysql_query("SELECT precio, fecha FROM productos WHERE id=".$_GET["id"])); while ($row=mysql_fetch_array($producto)){ $ydata[]=$row["precio"]; $datax[]=renombrarfecha($row["fecha"]); //echo $row["precio"]; //echo $row["fecha"]; } /* $merged->value->Show(true); $merged->value->SetFormat("$%d"); */ // Create the graph. These two calls are always required $graph = new Graph(400,350,"auto"); //$graph->SetColor("red"); $graph->SetBackgroundImage("../../img/fondo.png",BGIMG_FILLFRAME); $graph->SetScale("textint"); $graph->img->SetAntiAliasing(); $graph->xgrid->Show(); // Create the linear plot $lineplot=new LinePlot($ydata); $lineplot->SetColor("red");//color de la raya $lineplot->SetWeight(4);//anchura de la linea $lineplot->SetLegend("precio");//titulo del gráfico (en el medio) $lineplot->value-> Show();//Se muestra el valor exacto en el punto // Titulos a mostrar $graph->img->SetMargin(60,30,20,20); $graph->xaxis->SetTickLabels($datax); $graph->title->Set("Gráfica de variación de precios"); $graph->xaxis->title->Set("Fechas"); $graph->yaxis->title->Set(""); //$graph->ygrid->SetFill(true,'#[email protected]','#[email protected]'); // Add the plot to the graph $graph->Add($lineplot); // Display the graph $graph->Stroke(); ?> <img src="grafico_linea.php" alt="" border="0"> De todas formas he estado leyendo y no he encontrado ningún ejemplo en el que me modifique el intervalo de las coordenadas del tiempo, por eso quería saber si hay algún otro tipo de gráfico o manera de hacerlo. |