1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| function GenereImage()
{
[... Code générant mes tableaux de données depuis une base ...]
# Construction du graphe en Camembert
#=================================
// Size of graph
$width=750;
$height=350;
// Create the graph.
$graph_c = new PieGraph ($width,$height);
$graph_c->title->Set($Langue->REPARTITION_CAUSES);
$graph_c->title->SetFont(FF_FONT1,FS_BOLD,8);
$graph_c->subtitle->Set($Langue->REPARTITION_CAUSES_ST.$this->date_debut.$Langue->ET_LE.$this->date_fin);
$graph_c->subtitle->SetFont(FF_FONT1,FS_NORMAL,6);
$graph_c->footer->right->Set("(".$Langue->GENERE_LE." ".date("d/m/Y H:i:s").")");
$pie_plot = new PiePlot($tab_donnees_graphe);
$pie_plot->SetGuideLines(true,false);
$pie_plot->SetGuideLinesAdjust(1.1);
$pie_plot->SetSliceColors($tab_couleurs);
$pie_plot->SetLegends($tab_libelle_graphe);
$pie_plot->SetCenter(0.3,0.6);
$graph_c->Add($pie_plot);
# Construction du graphe en barre
#=========================================
// Size of graph
$width=750;
$height=count($tab_donnees_autres)*30;
// Create the graph.
$graph = new Graph($width,$height,"auto");
$graph->SetScale("textlin");
$graph->Set90AndMargin(250,20,50,20);
// Setup title
$graph->title->Set($Langue->DETAILS_AUTRE);
$graph->title->SetFont(FF_VERDANA,FS_BOLD,8);
$graph->SetShadow();
$graph->xaxis->SetTickLabels($tab_libelles_autres);
$graph->xaxis->SetFont(FF_VERDANA,FS_NORMAL,8);
$graph->xaxis->SetLabelAlign('right','center');
$graph->yaxis->scale->SetGrace(20);
// Now create a bar pot
$bplot = new BarPlot($tab_donnees_autres);
$bplot->SetFillColor("orange");
$bplot->SetShadow();
// We want to display the value of each bar at the top
$bplot->value->Show();
$bplot->value->SetFont(FF_ARIAL,FS_BOLD,8);
$bplot->value->SetAlign('left','center');
$bplot->value->SetColor("black","darkred");
$bplot->value->SetFormat('%d');
$graph->Add($bplot);
# On créé une image composée des deux graphes
#=========================================
$mgraph = new MGraph();
$xpos1=3;$ypos1=3;
$xpos2=3;$ypos2=360;
$mgraph->Add($graph_c,$xpos1,$ypos1);
$mgraph->Add($graph,$xpos2,$ypos2);
$mgraph->Stroke(_DOSSIER_IMAGES_JPGRAPH."stats_".$this->reference.".png");
} |
Partager