Voila tout le fichier courbe.php
<?php
//Fichiers nécéssaires
include ("../include/JPgraph/jpgraph.php");
include ("../include/JPgraph/jpgraph_line.php");
include ("../include/JPgraph/jpgraph_bar.php");
include ("../include/JPgraph/jpgraph_pie.php");
include ("../include/JPgraph/jpgraph_pie3d.php");
require ("FoncReport.php");
//Format des données
/* $titre = {"Nom du graphe","Axe des X","Axe des Y","Axe des Y2","Type de graphe","min axe Y","max axe Y","min axe Y2","max axe Y2"}
** Mois = 0 ; Valeur = 1
** Graphe ligne = 0 ; Graphe baton = 1 ; Graphe accumulation = 2 ; Camembert = 3
**
** $dataR[0] [nom] = {"nom de la courbe",0,"couleur"}
** $dataR[0][donnee] = {,0,1,2,3,4,5,6,7,8,9,10,11,etc}
*/
//Gestion des données pour le graphique
if(!isset($_GET['titre']) || !isset($_GET['donnees']))
echo "Erreur";
else
{
//Récupération des titres
$strT = $_GET['titre'];
$titre = unserialize(urldecode(stripslashes($strT)));
//$titre = array("cou","Mois",0,"",0,0,0,0,0);
//Récupération des valeurs
$strD = $_GET['donnees'];
$dataR = unserialize(urldecode(stripslashes($strD)));
//$dataR = array(array("nom" => array("courbe",0,"orange"),"donnee" => array(1,2,3,4,5,6,7,8,9,1,2,3)));
//Extraction des valeurs
foreach($dataR as $numCourbe => $courbe)
{
foreach($courbe as $type => $tableau)
{
if(ereg("nom",$type)) //Nom
{
$yDataName[$numCourbe] = $tableau[0];
$typeCourbe[$numCourbe] = $tableau[1];
$couleurCourbe[$numCourbe] = $tableau[2];
}
else //Données
{
for($i=0 ; $i<sizeof($tableau) ; $i++)
$yData[$numCourbe][$i] = $tableau[$i];
}
}
}
}
//Affichage du graphe
if($yData[0] != NULL)
{
if($typeCourbe[0] == 3) //Camembert
{
//Création du graphe
$graph = new PieGraph(700,400,"auto");
$graph->SetShadow();
//Initialisation des titres
//img
$graph->img->SetImgFormat("gif");
$graph->title->Set($yDataName[0]);
$graph->title->SetFont(FF_ARIAL,FS_NORMAL,12);
//Création du camembert
$piePlot = new PiePlot3D($yData[0]);
$piePlot->SetSize(0.5);
$piePlot->SetCenter(0.45);
//Affichage du graphe
$graph->add($piePlot);
$graph->Stroke();
}
else
{
//Initialisation des variables
$i = 0;
$j = 0;
$k = 0;
$barPlot = array();
$accPlot = array();
$linePlot = array();
//Initialisation du graphe
//Création du graphe
$graph = new Graph(900,400,"auto");
$graph->SetScale("textlin",$titre[5],$titre[6]);
if($titre[2] != '0')
$graph->SetY2Scale("lin",$titre[7],$titre[8]);
//Initialisation des titres
$graph->img->SetImgFormat("gif");
$graph->img->SetMargin(60,200,20,40);
$graph->title->Set($titre[0]);
$graph->xaxis->title->Set($titre[1]);
$graph->yaxis->title->Set($titre[3]);
if($titre[2] != '0')
$graph->y2axis->title->Set($titre[2]);
$graph->title->SetFont(FF_ARIAL,FS_NORMAL,12);
$graph->xaxis->title->SetFont(FF_ARIAL,FS_NORMAL,12);
$graph->yaxis->title->SetFont(FF_ARIAL,FS_NORMAL,12);
if($titre[2] != '0')
$graph->y2axis->title->SetFont(FF_ARIAL,FS_NORMAL,12);
$graph->SetMarginColor('#F7F7F7');
$graph->SetShadow();
//Belle image de fond
//$graph->SetBackgroundImage('Includes/FrancePl.jpg',BGIMG_CENTER);
//Axe des X
if($titre[4]); //Valeur
else //Mois
$graph->xaxis->SetTickLabels($gDateLocale->GetShortMonth());
//Tableau de couleurs
$couleur = array("red","blue","orange","darkgreen","yellow","darkred","brown","green","navy","");
//Création des courbes
for($numeroCourbe=0 ; $numeroCourbe<sizeof($yData) ; $numeroCourbe++)
{
//Couleur
$couleurChoisie = (($couleurCourbe[$numeroCourbe] != null) ? $couleurCourbe[$numeroCourbe] : $couleur[$numeroCourbe]);
if($typeCourbe[$numeroCourbe] == 1) //Bar Graphe
{
$barPlot[$i] = new BarPlot($yData[$numeroCourbe]);
$barPlot[$i]->SetFillColor($couleurChoisie."@0.5");
$barPlot[$i]->SetShadow("[email protected]");
$barPlot[$i]->SetLegend($yDataName[$numeroCourbe]);
$i++;
}
else if($typeCourbe[$numeroCourbe] == 2) //Accumulation Graphe
{
$accPlot[$j] = new BarPlot($yData[$numeroCourbe]);
$accPlot[$j]->SetFillColor($couleurChoisie."@0.5");
$accPlot[$j]->SetShadow("[email protected]");
$accPlot[$j]->SetLegend($yDataName[$numeroCourbe]);
$j++;
}
else //Courbe 0
{
$linePlot[$k] = new Lineplot($yData[$numeroCourbe]);
$linePlot[$k]->SetColor($couleurChoisie);
$linePlot[$k]->SetWeight(2);
$linePlot[$k]->SetLegend($yDataName[$numeroCourbe]);
//Marque
$linePlot[$k]->mark->SetType(MARK_SQUARE);
$linePlot[$k]->mark->SetColor($couleurChoisie);
$linePlot[$k]->mark->SetFillColor($couleurChoisie."@0.5");
$linePlot[$k]->mark->SetWidth(3);
if($titre[2] != '0')
{
$linePlot[$k]->SetBarCenter(); //Centre la ligne
$graph->AddY2($linePlot[$k]);
}
else
$graph->Add($linePlot[$k]);
$k++;
}
}
//Ajout des courbes au graphe
if($i != 0) //Bar graphe
{
$groupBarPlot = new GroupBarPlot($barPlot);
$groupBarPlot->SetWidth(0.6);
$graph->Add($groupBarPlot);
}
if($j != 0) //Accumulation
{
$accBarPlot = new AccBarPlot($accPlot);
$accBarPlot->SetWidth(0.6);
$graph->Add($accBarPlot);
}
//Légendes position
$graph->legend->Pos(0.01,0.5,"right","center");
//Affichage du graphe
$graph->Stroke();
}
}
else
echo "Erreur : données sur l'axe Y non valides !!!";
?>
Voila tout le fichier courbe.php
[php]
<?php
//Fichiers nécéssaires
include ("../include/JPgraph/jpgraph.php");
include ("../include/JPgraph/jpgraph_line.php");
include ("../include/JPgraph/jpgraph_bar.php");
include ("../include/JPgraph/jpgraph_pie.php");
include ("../include/JPgraph/jpgraph_pie3d.php");
require ("FoncReport.php");
//Format des données
/* $titre = {"Nom du graphe","Axe des X","Axe des Y","Axe des Y2","Type de graphe","min axe Y","max axe Y","min axe Y2","max axe Y2"}
** Mois = 0 ; Valeur = 1
** Graphe ligne = 0 ; Graphe baton = 1 ; Graphe accumulation = 2 ; Camembert = 3
**
** $dataR[0] [nom] = {"nom de la courbe",0,"couleur"}
** $dataR[0][donnee] = {,0,1,2,3,4,5,6,7,8,9,10,11,etc}
*/
//Gestion des données pour le graphique
if(!isset($_GET['titre']) || !isset($_GET['donnees']))
echo "Erreur";
else
{
//Récupération des titres
$strT = $_GET['titre'];
$titre = unserialize(urldecode(stripslashes($strT)));
//$titre = array("cou","Mois",0,"",0,0,0,0,0);
//Récupération des valeurs
$strD = $_GET['donnees'];
$dataR = unserialize(urldecode(stripslashes($strD)));
//$dataR = array(array("nom" => array("courbe",0,"orange"),"donnee" => array(1,2,3,4,5,6,7,8,9,1,2,3)));
//Extraction des valeurs
foreach($dataR as $numCourbe => $courbe)
{
foreach($courbe as $type => $tableau)
{
if(ereg("nom",$type)) //Nom
{
$yDataName[$numCourbe] = $tableau[0];
$typeCourbe[$numCourbe] = $tableau[1];
$couleurCourbe[$numCourbe] = $tableau[2];
}
else //Données
{
for($i=0 ; $i<sizeof($tableau) ; $i++)
$yData[$numCourbe][$i] = $tableau[$i];
}
}
}
}
//Affichage du graphe
if($yData[0] != NULL)
{
if($typeCourbe[0] == 3) //Camembert
{
//Création du graphe
$graph = new PieGraph(700,400,"auto");
$graph->SetShadow();
//Initialisation des titres
//img
$graph->img->SetImgFormat("gif");
$graph->title->Set($yDataName[0]);
$graph->title->SetFont(FF_ARIAL,FS_NORMAL,12);
//Création du camembert
$piePlot = new PiePlot3D($yData[0]);
$piePlot->SetSize(0.5);
$piePlot->SetCenter(0.45);
//Affichage du graphe
$graph->add($piePlot);
$graph->Stroke();
}
else
{
//Initialisation des variables
$i = 0;
$j = 0;
$k = 0;
$barPlot = array();
$accPlot = array();
$linePlot = array();
//Initialisation du graphe
//Création du graphe
$graph = new Graph(900,400,"auto");
$graph->SetScale("textlin",$titre[5],$titre[6]);
if($titre[2] != '0')
$graph->SetY2Scale("lin",$titre[7],$titre[8]);
//Initialisation des titres
$graph->img->SetImgFormat("gif");
$graph->img->SetMargin(60,200,20,40);
$graph->title->Set($titre[0]);
$graph->xaxis->title->Set($titre[1]);
$graph->yaxis->title->Set($titre[3]);
if($titre[2] != '0')
$graph->y2axis->title->Set($titre[2]);
$graph->title->SetFont(FF_ARIAL,FS_NORMAL,12);
$graph->xaxis->title->SetFont(FF_ARIAL,FS_NORMAL,12);
$graph->yaxis->title->SetFont(FF_ARIAL,FS_NORMAL,12);
if($titre[2] != '0')
$graph->y2axis->title->SetFont(FF_ARIAL,FS_NORMAL,12);
$graph->SetMarginColor('#F7F7F7');
$graph->SetShadow();
//Belle image de fond
//$graph->SetBackgroundImage('Includes/FrancePl.jpg',BGIMG_CENTER);
//Axe des X
if($titre[4]); //Valeur
else //Mois
$graph->xaxis->SetTickLabels($gDateLocale->GetShortMonth());
//Tableau de couleurs
$couleur = array("red","blue","orange","darkgreen","yellow","darkred","brown","green","navy","");
//Création des courbes
for($numeroCourbe=0 ; $numeroCourbe<sizeof($yData) ; $numeroCourbe++)
{
//Couleur
$couleurChoisie = (($couleurCourbe[$numeroCourbe] != null) ? $couleurCourbe[$numeroCourbe] : $couleur[$numeroCourbe]);
if($typeCourbe[$numeroCourbe] == 1) //Bar Graphe
{
$barPlot[$i] = new BarPlot($yData[$numeroCourbe]);
$barPlot[$i]->SetFillColor($couleurChoisie."@0.5");
$barPlot[$i]->SetShadow("
[email protected]");
$barPlot[$i]->SetLegend($yDataName[$numeroCourbe]);
$i++;
}
else if($typeCourbe[$numeroCourbe] == 2) //Accumulation Graphe
{
$accPlot[$j] = new BarPlot($yData[$numeroCourbe]);
$accPlot[$j]->SetFillColor($couleurChoisie."@0.5");
$accPlot[$j]->SetShadow("
[email protected]");
$accPlot[$j]->SetLegend($yDataName[$numeroCourbe]);
$j++;
}
else //Courbe 0
{
$linePlot[$k] = new Lineplot($yData[$numeroCourbe]);
$linePlot[$k]->SetColor($couleurChoisie);
$linePlot[$k]->SetWeight(2);
$linePlot[$k]->SetLegend($yDataName[$numeroCourbe]);
//Marque
$linePlot[$k]->mark->SetType(MARK_SQUARE);
$linePlot[$k]->mark->SetColor($couleurChoisie);
$linePlot[$k]->mark->SetFillColor($couleurChoisie."@0.5");
$linePlot[$k]->mark->SetWidth(3);
if($titre[2] != '0')
{
$linePlot[$k]->SetBarCenter(); //Centre la ligne
$graph->AddY2($linePlot[$k]);
}
else
$graph->Add($linePlot[$k]);
$k++;
}
}
//Ajout des courbes au graphe
if($i != 0) //Bar graphe
{
$groupBarPlot = new GroupBarPlot($barPlot);
$groupBarPlot->SetWidth(0.6);
$graph->Add($groupBarPlot);
}
if($j != 0) //Accumulation
{
$accBarPlot = new AccBarPlot($accPlot);
$accBarPlot->SetWidth(0.6);
$graph->Add($accBarPlot);
}
//Légendes position
$graph->legend->Pos(0.01,0.5,"right","center");
//Affichage du graphe
$graph->Stroke();
}
}
else
echo "Erreur : données sur l'axe Y non valides !!!";
?>
[/php]