Ver Mensaje Individual
  #4 (permalink)  
Antiguo 17/11/2009, 11:22
ronald_bond
 
Fecha de Ingreso: noviembre-2009
Ubicación: Lima
Mensajes: 1
Antigüedad: 14 años, 5 meses
Puntos: 0
Respuesta: graficas con amCharts

Hola estoy trabajando con jpgraph es muy buena si quieres sacar datos de una bd aca esta el script :
<?php
require_once ("jpgraph/src/jpgraph.php");
require_once ("jpgraph/src/jpgraph_bar.php");

include_once("php/conexion.class.PHP");
$cn=new Singleton();
$cn=$cn->conectandome();

$sql = mysql_query("SELECT tb_tipo_servicio.servicio, Count(tb_trabajos.id_trabajo) AS trabajos
FROM
tb_tipo_servicio , tb_trabajos
WHERE
tb_trabajos.fk_id_servicio = tb_tipo_servicio.id_servicio
GROUP BY
tb_tipo_servicio.servicio");
$i=0;
$j=0;
while($data=mysql_fetch_array($sql)){
$titulos[$j]=$data[0];
$info[$i]=$data[1];
$i++;
$j++;
}

// Cree el gráfico y configuración de los parámetros básicos
$graph = new Graph(415,320,'auto');
$graph->img->SetMargin(40,30,40,50);
$graph->SetScale("textint");
$graph->SetFrame(true,'blue',1);
$graph->SetColor('lightblue');
$graph->SetMarginColor('lightblue');

// Configuración de X-etiquetas del eje
$a = $gDateLocale->GetShortMonth();
$graph->xaxis->SetTickLabels($titulos);
$graph->xaxis->SetFont(FF_FONT1);
$graph->xaxis->SetColor('darkblue','black');

// Setup "oculto" eje "por el color dado el mismo
// como el fondo (esto también puede hacerse mediante la creación del peso a cero)
$graph->yaxis->SetColor('lightblue','darkblue');
$graph->ygrid->SetColor('white');

// Título del gráfico de instalación y fuente
$graph->title->Set('Trabajos Más realizados');
$graph->title->SetFont(FF_FONT2,FS_BOLD);
$graph->xaxis->SetTitle('Servicios','center');
$graph->xaxis->SetTitleMargin(10);
$graph->xaxis->title->SetFont(FF_FONT2,FS_BOLD);

// Agregue un poco de gracia a la parte superior de modo que la escala no
// final exactamente en el valor máximo.
$graph->yaxis->scale->SetGrace(100);


// Create a bar pot
$bplot = new BarPlot($info);
$bplot->SetFillColor('darkblue');
$bplot->SetColor('darkblue');
$bplot->SetWidth(0.5);
$bplot->SetShadow('darkgray');

// Setup the values that are displayed on top of each bar
// Must use TTF fonts if we want text at an arbitrary angle
$bplot->value->Show();
$bplot->value->SetFont(FF_ARIAL,FS_NORMAL,8);
$bplot->value->SetFormat('%d');
$bplot->value->SetColor('darkred');
$bplot->value->SetAngle(45);
$graph->Add($bplot);

// Por último movimiento de la gráfica
$graph->Stroke();
?>