Sólo lo comentaba. Cada cual que use la libería que se ajuste a su proyecto/ trabajo
Pues como ya te dije yo haría el include pasando los parámetros.
Vamos a suponer que tienes 2 páginas: index.php y grafica.php
index.php
Código PHP:
include('grafica.php?s=votos&t=encuesta');
include('grafica.php?s=votos&t=fotos');
grafica.php
Código PHP:
<?php
//En los gets tendrías que validar que los datos son correctos.
$campo=$_GET['s'];
$tabla=$GET['t'];
include("conex.php");
include("jpgraph/src/jpgraph.php");
include("jpgraph/src/jpgraph_pie.php");
include("jpgraph/src/jpgraph_pie3d.php");
$query = mysql_query("SELECT ".$campo." FROM ".$tabla);
while($row = mysql_fetch_array($query))
{
$data[] = $row[0];
}
$graph = new PieGraph(550,300,"auto");
$graph->img->SetAntiAliasing();
$graph->SetMarginColor('gray');
//$graph->SetShadow();
// Setup margin and titles
$graph->title->Set("Grafica");
$p1 = new PiePlot3D($data);
$p1->SetSize(0.45);
$p1->SetCenter(0.4);
// Setup slice labels and move them into the plot
$p1->value->SetFont(FF_FONT1,FS_BOLD);
$p1->value->SetColor("black");
$p1->SetLabelPos(0.5);
$p1->SetLegends($can);
$p1->ExplodeAll();
$graph->Add($p1);
$graph->Stroke();
?>
Ya depués lo acondicionas a tu manera, le pasas un parametro para el Where, para el título, el color de fondo...