IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Bibliothèques et frameworks PHP Discussion :

[JpGraph] Graphique en PHP


Sujet :

Bibliothèques et frameworks PHP

  1. #1
    Nouveau Candidat au Club
    Homme Profil pro
    Inscrit en
    Décembre 2012
    Messages
    3
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Suisse

    Informations forums :
    Inscription : Décembre 2012
    Messages : 3
    Points : 1
    Points
    1
    Par défaut [JpGraph] Graphique en PHP
    Bonjour,

    Dans le cadre de mon apprentissage, j'ai un projet web à réaliser et j'ai besoin d'aide.

    Une page web affiche une simple <table> contenant des données d'une base distante, je souhaite afficher les données de mon tableau sous forme de graphique (Type diagramme de courbes). Existe-t-il un outil simple pour le faire ?

    Merci d'avance,

    Meilleures salutations.

  2. #2
    Modérateur
    Avatar de sabotage
    Homme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    29 208
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2005
    Messages : 29 208
    Points : 44 155
    Points
    44 155
    Par défaut
    il en existe des dizaines une recherche google s impose à toi.
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

  3. #3
    Nouveau Candidat au Club
    Homme Profil pro
    Inscrit en
    Décembre 2012
    Messages
    3
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Suisse

    Informations forums :
    Inscription : Décembre 2012
    Messages : 3
    Points : 1
    Points
    1
    Par défaut
    Merci pour la réponse, j'ai donc opté pour JPgraph, par contre, j'arrive pas à afficher mon diagramme,

    Voici mon code :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    <?php
     
    	$sql = 'SELECT Date, Chauffage, Eclairage, Cuisine, Medias, Autres FROM tbl_data';
    	print_r(mysql_error());
    	$req = mysql_query($sql);
    	while ( ($data = mysql_fetch_assoc($req))!== false) {
    		$conso1[] = $data['Chauffage'];
    		$conso2[] = $data['Cuisine'];
    		$conso3[] = $data['Eclairage'];
    		$conso4[] = $data['Medias'];
    		$conso5[] = $data['Autres'];
    		$dates[] = $data['Date'];
    	}
     
    	/* JPgraph */
     
    	require_once ('src/jpgraph.php');
    	require_once ('src/jpgraph_line.php');
    	require_once("src/jpgraph_date.php");
     
    	// Setup the graph
    	$graph = new Graph(10000,500);
    	$graph->SetScale("textlin");
     
    	//$theme_class=new UniversalTheme;
    	$theme_class=new AquaTheme;
     
    	$graph->SetTheme($theme_class);
    	$graph->img->SetAntiAliasing(false);
    	$graph->title->Set('Evolution de la consommation');
    	$graph->SetBox(false);
     
    	$graph->img->SetAntiAliasing();
     
    	$graph->yaxis->HideZeroLabel();
    	$graph->yaxis->HideLine(false);
    	$graph->yaxis->HideTicks(false,false);
     
    	$graph->xgrid->Show();
    	$graph->xgrid->SetLineStyle("solid");
    	$graph->xaxis->SetTickLabels($dates);	// l'axe du bas
     
    	$graph->xaxis->SetFont(FF_ARIAL,FS_NORMAL,6);
    	$graph->xgrid->SetColor('#E3E3E3');
     
    	// Les lignes
    	$p1 = new LinePlot($conso1);
    	$graph->Add($p1);
    	$p1->SetColor("#B254FF");
    	$p1->SetLegend('Eclairage');
     
    	$p1 = new LinePlot($conso2);
    	$graph->Add($p1);
    	$p1->SetColor("#38FFFF");
    	$p1->SetLegend('MenageCuisine');
     
    	$p1 = new LinePlot($conso3);
    	$graph->Add($p1);
    	$p1->SetColor("#3019FF");
    	$p1->SetLegend('MenageLavage');
     
    	$p1 = new LinePlot($conso4);
    	$graph->Add($p1);
    	$p1->SetColor("#90FF00");
    	$p1->SetLegend('PetitMenage');
     
    	$p1 = new LinePlot($conso5);
    	$graph->Add($p1);
    	$p1->SetColor("#FF8300");
    	$p1->SetLegend('LoisirBureau');
     
    	$graph->legend->SetFrameWeight(1);
     
    	// Output line
    	$graph->Stroke();
    	?>

    Quelqu'un a une idée ?

    Merci

  4. #4
    Modérateur
    Avatar de sabotage
    Homme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    29 208
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2005
    Messages : 29 208
    Points : 44 155
    Points
    44 155
    Par défaut
    Qu'obtiens-tu ?
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

  5. #5
    Nouveau Candidat au Club
    Homme Profil pro
    Inscrit en
    Décembre 2012
    Messages
    3
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Suisse

    Informations forums :
    Inscription : Décembre 2012
    Messages : 3
    Points : 1
    Points
    1
    Par défaut
    Je n'obtenais rien mais j'ai trouvé !

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    	/* REQUETE */
    	$sql = 'SELECT Date, Chauffage, Eclairage, Cuisine, Medias, Autres FROM tbl_data';
    	print_r(mysql_error());
    	$req = mysql_query($sql);
    	while ( ($data = mysql_fetch_assoc($req))!== false) {
    		$conso1[] = $data['Chauffage'];
    		$conso2[] = $data['Cuisine'];
    		$conso3[] = $data['Eclairage'];
    		$conso4[] = $data['Medias'];
    		$conso5[] = $data['Autres'];
    		$dates[] = $data['Heure'];
    	}
     
    	/* JPgraph */
     
    	require_once ('src/jpgraph.php');
    	require_once ('src/jpgraph_line.php');
    	require_once("src/jpgraph_date.php");
     
    	// Setup the graph
    	$graph = new Graph(2000,1000);
    	$graph->SetScale("textlin");
     
    	//$theme_class=new UniversalTheme;
    	$theme_class=new AquaTheme;
     
    	$graph->SetTheme($theme_class);
    	$graph->img->SetAntiAliasing(false);
    	$graph->title->Set('Evolution de la consommation');
    	$graph->SetBox(false);
     
    	$graph->img->SetAntiAliasing();
     
    	$graph->yaxis->HideZeroLabel();
    	$graph->yaxis->HideLine(false);
    	$graph->yaxis->HideTicks(false,false);
     
    	$graph->xgrid->Show();
    	$graph->xgrid->SetLineStyle("solid");
    	$graph->xaxis->SetTickLabels($dates);	// l'axe du bas
     
    	$graph->xaxis->SetFont(FF_ARIAL,FS_NORMAL,6);
    	$graph->xgrid->SetColor('#E3E3E3');
     
    	// Les lignes
    	$p1 = new LinePlot($conso1);
    	$graph->Add($p1);
    	$p1->SetColor("#B254FF");
    	$p1->SetLegend('Eclairage');
     
    	$p1 = new LinePlot($conso2);
    	$graph->Add($p1);
    	$p1->SetColor("#38FFFF");
    	$p1->SetLegend('MenageCuisine');
     
    	$p1 = new LinePlot($conso3);
    	$graph->Add($p1);
    	$p1->SetColor("#3019FF");
    	$p1->SetLegend('MenageLavage');
     
    	$p1 = new LinePlot($conso4);
    	$graph->Add($p1);
    	$p1->SetColor("#90FF00");
    	$p1->SetLegend('PetitMenage');
     
    $p1 = new LinePlot($conso5);
    	$graph->Add($p1);
    	$p1->SetColor("#FF8300");
    	$p1->SetLegend('LoisirBureau');
     
    	$graph->legend->SetFrameWeight(1);
     
    	// Output line
    	$graph->Stroke("graph.png");
    	echo "<center><img src='graph.png' /></center>";
    	?>
    Voilà le code si ça peut aider quelqu'un !

    Merci beaucoup pour toi aide

Discussions similaires

  1. [JpGraph] Représentation graphique en PHP
    Par erman_yazid dans le forum Bibliothèques et frameworks
    Réponses: 3
    Dernier message: 04/03/2008, 14h09
  2. probleme graphiques avec php
    Par jadoo dans le forum Général Java
    Réponses: 13
    Dernier message: 30/11/2006, 11h38
  3. [Graphique] Générer des graphiques en php
    Par gabychon dans le forum Bibliothèques et frameworks
    Réponses: 5
    Dernier message: 17/01/2006, 22h56
  4. [Graphique] Créer des graphiques en PHP
    Par neXistPa dans le forum Bibliothèques et frameworks
    Réponses: 1
    Dernier message: 08/01/2006, 13h26

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo