Ver Mensaje Individual
  #2 (permalink)  
Antiguo 27/10/2007, 22:09
Avatar de Carxl
Carxl
Colaborador
 
Fecha de Ingreso: agosto-2006
Ubicación: Bogotá
Mensajes: 2.993
Antigüedad: 17 años, 9 meses
Puntos: 70
De acuerdo Re: Duda usando jpgraph

Hola Helacer!! Cómo vas??

Mira este es uno de los tantos códigos que he utilizado para generar gráficos de barras:

Código PHP:
<?php
$data1y
=array($tenero,$tfebrero,$tmarzo,$tabril,$tmayo,$tjunio,$tjulio,$tagosto,$tseptiembre,$toctubre,$tnoviembre,$tdiciembre);
$data2y=array($gtenero,$gtfebrero,$gtmarzo,$gtabril,$gtmayo,$gtjunio,$gtjulio,$gtagosto,$gtseptiembre,$gtoctubre,$gtnoviembre,$gtdiciembre);
$datax=array('Ene''Feb','Mar','Abr''May','Jun','Jul','Ago','Sep','Oct','Nov','Dic');

// Create the graph. These two calls are always required
$graph = new Graph(750,350,"auto");    
$graph->SetScale("textlin");

$graph->SetShadow();
$graph->img->SetMargin(100,30,20,40);

//crear leyenda
/*$graph->Legend->Pos(0.02,0.2,"right","center");
$b1plot->SetLegend("Gastos");
$b2plot->SetLegend("Ingresos");*/


// Create the bar plots
$b1plot = new BarPlot($data1y);
$b1plot->SetFillGradient("yellow","red",GRAD_VER);
$b1plot->SetWidth(20);
$b2plot = new BarPlot($data2y);
$b2plot->SetFillGradient("lightsteelblue","navy",GRAD_VER);
$b2plot->SetWidth(20);

//crear leyenda
$graph->legend->Pos(0.02,0.2,"right","center");
$b1plot->SetLegend("Gastos");
$b2plot->SetLegend("Ingresos reales + asignados");



// Create the grouped bar plot
$gbplot = new GroupBarPlot(array($b1plot,$b2plot));

// ...and add it to the graPH
$graph->Add($gbplot);

$graph->title->Set("RELACION GRAFICA INGRESOS - GASTOS AÑO $anno");
$graph->xaxis->title->Set("Mes");
//$graph->yaxis->SetLabelAlign("nter",'center');
$graph->yaxis->title->Set("");

$graph->title->SetFont(FF_FONT1,FS_BOLD);
$graph->xaxis->SetTickLabels($datax);
$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);

$txt=new Text("Valor");
$txt->Pos(10,180);
$txt->SetFont(FF_FONT1,FS_BOLD);
//$txt->SetBox('yellow','navy','gray');
$txt->SetOrientation("v");
$txt->SetColor("black");
$graph->AddText($txt);


// Display the graph
$graph->Stroke();
?>
<img src="graficas.php?ano=<?php echo $anno?>" alt="Relación gráfica ingresos - egresos ejecutados año <?php echo $anno?>">
Fíjate en el array $datax(tercera linea), son los titulos del eje X

Espero te sirva!!, cualquier cosa me dices
__________________
Hay 10 tipos de personas, los que entienden binario y los que no. (Anónimo)
www.programandoweb.com