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] Appel page .php, mon code jpgraph, via page .html


Sujet :

Bibliothèques et frameworks PHP

  1. #1
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Mai 2008
    Messages
    103
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : France, Bas Rhin (Alsace)

    Informations forums :
    Inscription : Mai 2008
    Messages : 103
    Points : 36
    Points
    36
    Par défaut [JpGraph] Appel page .php, mon code jpgraph, via page .html
    Bonjour,

    Voila je voudrais, dans un but d'écriture propre de code, appeler une page .php qui contient le code du tracé de la courbe par l'intermédiaire de ma page principale html.

    Pensez vous que cela est possible ?
    Comment dois gérer les appels dans chaque page ?

    Ce que j'ai fais :
    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
    ------Page HTML--------
     
    <div id="graphCorelMet6">
    	<?php $connexion->gant(); ?>
    	<img src="monGrapique6.png" />
    </div>
     
    ------Page PHP-------
    class Connexion {
     
    function gantt()
    		{
    			echo "<?php
    			include_once (\"graph-jpgraph/src/jpgraph.php\");
    			include_once (\"graph-jpgraph/src/jpgraph_gantt.php\");
    
    			$graph = new GanttGraph();
    			$graph->title->Set(\"Using the builtin icons\");
    
    blablablabla
    
                            $graph->Add($bar);
    			$graph->Stroke('monGrapique6.png');
    			} ?>";
    		}
    Mais vous l'aurez compris ce code ne marche pas.

    Pouvez vous m'aider s'il vous plait ?

    Je vous remercie d'avance.

  2. #2
    Membre actif Avatar de BlackSmith
    Inscrit en
    Mars 2008
    Messages
    181
    Détails du profil
    Informations personnelles :
    Âge : 37

    Informations forums :
    Inscription : Mars 2008
    Messages : 181
    Points : 207
    Points
    207
    Par défaut
    Transforme ta fonction en fonction static
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    class Connexion {
     
    public static function gantt()
    		{
    Et tu l'appelle comme ceci
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    <div id="graphCorelMet6">
    	<?php $connexion::gant(); ?>
    	<img src="monGrapique6.png" />
    </div>
    ou alors tu modifie seulement l'appel par
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    <div id="graphCorelMet6">
    	<?php 
        $connexion = new connexion();
        $connexion::gant(); ?>
    	<img src="monGrapique6.png" />
    </div>

  3. #3
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Mai 2008
    Messages
    103
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : France, Bas Rhin (Alsace)

    Informations forums :
    Inscription : Mai 2008
    Messages : 103
    Points : 36
    Points
    36
    Par défaut
    Merci pour la reponse mais cela ne marche pas.

    Question :
    Dans le code de la fonction elle même, faut-il que je fasse un
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    echo "la fonction écrite en php"
    ou alors un
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    "directment la fonction en php"

  4. #4
    Membre actif Avatar de chtipitou
    Profil pro
    Étudiant
    Inscrit en
    Mars 2006
    Messages
    175
    Détails du profil
    Informations personnelles :
    Âge : 37
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mars 2006
    Messages : 175
    Points : 214
    Points
    214
    Par défaut
    Citation Envoyé par rudylar Voir le message
    Bonjour,

    Voila je voudrais, dans un but d'écriture propre de code, appeler une page .php qui contient le code du tracé de la courbe par l'intermédiaire de ma page principale html.

    Pensez vous que cela est possible ?
    Comment dois gérer les appels dans chaque page ?

    Ce que j'ai fais :
    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
    ------Page HTML--------
     
    <div id="graphCorelMet6">
    	<?php $connexion->gant(); ?>
    	<img src="monGrapique6.png" />
    </div>
     
    ------Page PHP-------
    class Connexion {
     
    function gantt()
    		{
    			echo "<?php
    			include_once (\"graph-jpgraph/src/jpgraph.php\");
    			include_once (\"graph-jpgraph/src/jpgraph_gantt.php\");
    
    			$graph = new GanttGraph();
    			$graph->title->Set(\"Using the builtin icons\");
    
    blablablabla
    
                            $graph->Add($bar);
    			$graph->Stroke('monGrapique6.png');
    			} ?>";
    		}
    Mais vous l'aurez compris ce code ne marche pas.

    Pouvez vous m'aider s'il vous plait ?

    Je vous remercie d'avance.
    je cromprend pas pourquoi dans une classe php tu fais un echo de code php Oo

    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
    class Connexion {
     
    function gantt()
    		{
    			include_once ("graph-jpgraph/src/jpgraph.php");
    			include_once ("graph-jpgraph/src/jpgraph_gantt.php");
     
    			$graph = new GanttGraph();
    			$graph->title->Set("Using the builtin icons");
     
    blablablabla
     
                            $graph->Add($bar);
    			$graph->Stroke('monGrapique6.png');
    			}
    		}
    c'est pas plus logic comme ca ?

  5. #5
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Mai 2008
    Messages
    103
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : France, Bas Rhin (Alsace)

    Informations forums :
    Inscription : Mai 2008
    Messages : 103
    Points : 36
    Points
    36
    Par défaut
    Oui pour moi aussi cela serait logique mais pour le graph gantt cela ne marche pas.

    C'est très bizarre car lorsque je met le traçage d'un graph courbe à la place cela marche.

    Et le code du graph gantt est correct car il est tiré des exemple et je l'ai testé à part.

  6. #6
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Mai 2008
    Messages
    103
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : France, Bas Rhin (Alsace)

    Informations forums :
    Inscription : Mai 2008
    Messages : 103
    Points : 36
    Points
    36
    Par défaut
    Alors là il y à effectivement quelque chose de très magique .....

    Voici le code du graph gantt qui ne marche pas :
    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
    function gantt()
    		{
    			include_once ("graph-jpgraph/src/jpgraph.php");
    			include_once ("graph-jpgraph/src/jpgraph_gantt.php");
     
    			// Basic Gantt graph
    			$graph = new GanttGraph();
    			$graph->title->Set("Using the builtin icons");
     
    			// Explicitely set the date range 
    			// (Autoscaling will of course also work)
    			$graph->SetDateRange('2001-10-06','2002-4-10');
     
     
    			// 1.5 line spacing to make more room
    			$graph->SetVMarginFactor(1.5);
     
    			// Setup some nonstandard colors
    			$graph->SetMarginColor('lightgreen@0.8');
    			$graph->SetBox(true,'yellow:0.6',2);
    			$graph->SetFrame(true,'darkgreen',4);
    			$graph->scale->divider->SetColor('yellow:0.6');
    			$graph->scale->dividerh->SetColor('yellow:0.6');
     
    			// Display month and year scale with the gridlines
    			$graph->ShowHeaders(GANTT_HMONTH | GANTT_HYEAR);
    			$graph->scale->month->grid->SetColor('gray');
    			$graph->scale->month->grid->Show(true);
    			$graph->scale->year->grid->SetColor('gray');
    			$graph->scale->year->grid->Show(true);
     
    			// For the titles we also add a minimum width of 100 pixels for the Task name column
    			$graph->scale->actinfo->SetColTitles(
    			    array('Note','Task','Duration','Start','Finish'),array(30,100));
    			$graph->scale->actinfo->SetBackgroundColor('green:0.5@0.5');
    			$graph->scale->actinfo->SetFont(FF_ARIAL,FS_NORMAL,10);
    			$graph->scale->actinfo->vgrid->SetStyle('solid');
    			$graph->scale->actinfo->vgrid->SetColor('gray');
     
    			// Uncomment this to keep the columns but show no headers
    			//$graph->scale->actinfo->Show(false);
     
    			// Setup the icons we want to use
    			$erricon = new IconImage(GICON_FOLDER,0.6);
    			$startconicon = new IconImage(GICON_FOLDEROPEN,0.6);
    			$endconicon = new IconImage(GICON_TEXTIMPORTANT,0.5);
     
    			// Store the icons in the first column and use plain text in the others
    			$data = array(
    				array(0,array($erricon,"Pre-study","102 days","23 Nov '01","1 Mar '02")
    				      , "2001-11-23","2002-03-1",FF_ARIAL,FS_NORMAL,8),
    				array(1,array($startconicon,"Prototype","21 days","26 Oct '01","16 Nov '01"),
    				      "2001-10-26","2001-11-16",FF_ARIAL,FS_NORMAL,8),
    				array(2,array($endconicon,"Report","12 days","1 Mar '02","13 Mar '02"),
    				      "2002-03-01","2002-03-13",FF_ARIAL,FS_NORMAL,8)
    			);
     
    			// Create the bars and add them to the gantt chart
    			for($i=0; $i<count($data); ++$i) {
    				$bar = new GanttBar($data[$i][0],$data[$i][1],$data[$i][2],$data[$i][3],"[50%]",10);
    				if( count($data[$i])>4 )
    					$bar->title->SetFont($data[$i][4],$data[$i][5],$data[$i][6]);
    				$bar->SetPattern(BAND_RDIAG,"yellow");
    				$bar->SetFillColor("gray");
    				$bar->progress->Set(0.5);
    				$bar->progress->SetPattern(GANTT_SOLID,"darkgreen");
    				$bar->title->SetCSIMTarget(array('#1'.$i,'#2'.$i,'#3'.$i,'#4'.$i,'#5'.$i),array('11'.$i,'22'.$i,'33'.$i));
    				$graph->Add($bar);
    			}
     
    			$graph->Stroke('monGrapique6.png');			
    		}
    et voici un code d'un gantt qui marche :
    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
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    include ("../jpgraph.php");
    include ("../jpgraph_gantt.php");
     
    $graph = new GanttGraph(0,0,"auto");
    $graph->SetShadow();
     
    // Add title and subtitle
    $graph->title->Set("A nice main title");
    $graph->title->SetFont(FF_ARIAL,FS_BOLD,12);
    $graph->subtitle->Set("(Draft version)");
     
    // Show day, week and month scale
    $graph->ShowHeaders(GANTT_HDAY | GANTT_HWEEK | GANTT_HMONTH);
     
    // Instead of week number show the date for the first day in the week
    // on the week scale
    $graph->scale->week->SetStyle(WEEKSTYLE_FIRSTDAY);
     
    // Make the week scale font smaller than the default
    $graph->scale->week->SetFont(FF_FONT0);
     
    // Use the short name of the month together with a 2 digit year
    // on the month scale
    $graph->scale->month->SetStyle(MONTHSTYLE_SHORTNAMEYEAR4);
    $graph->scale->month->SetFontColor("white");
    $graph->scale->month->SetBackgroundColor("blue");
     
    // Format the bar for the first activity
    // ($row,$title,$startdate,$enddate)
    $activity = new GanttBar(0,"Project","2001-12-21","2002-02-20");
     
    // Yellow diagonal line pattern on a red background
    $activity->SetPattern(BAND_RDIAG,"yellow");
    $activity->SetFillColor("red");
     
    // Add a right marker
    $activity->rightMark->Show();	
    $activity->rightMark->SetType(MARK_FILLEDCIRCLE);
    $activity->rightMark->SetWidth(13);
    $activity->rightMark->SetColor("red");
    $activity->rightMark->SetFillColor("red");
    $activity->rightMark->title->Set("M5");
    $activity->rightMark->title->SetFont(FF_ARIAL,FS_BOLD,12);
    $activity->rightMark->title->SetColor("white");
     
    // Set absolute height
    $activity->SetHeight(1);
     
     
    // Format the bar for the second activity
    // ($row,$title,$startdate,$enddate)
    $activity2 = new GanttBar(1,"Project","2001-12-21","2002-02-20");
     
    // Yellow diagonal line pattern on a red background
    $activity2->SetPattern(BAND_RDIAG,"yellow");
    $activity2->SetFillColor("red");
     
    // Add a right marker
    $activity2->rightMark->Show();	
    $activity2->rightMark->SetType(MARK_FILLEDCIRCLE);
    $activity2->rightMark->SetWidth(13);
    $activity2->rightMark->SetColor("red");
    $activity2->rightMark->SetFillColor("red");
    $activity2->rightMark->title->Set("M5");
    $activity2->rightMark->title->SetFont(FF_ARIAL,FS_BOLD,12);
    $activity2->rightMark->title->SetColor("white");
     
    // Set absolute height
    $activity2->SetHeight(1);
     
     
    // Finally add the bar to the graph
    $graph->Add($activity);
    $graph->Add($activity2);
     
    // Create a miletone
    $milestone = new MileStone(2,"Milestone","2002-01-15","2002-01-15");
    $milestone->title->SetColor("black");
    $milestone->title->SetFont(FF_FONT1,FS_BOLD);
    $graph->Add($milestone);
     
    // Add a vertical line
    $vline = new GanttVLine("2001-12-24","Phase 1");
    $vline->SetDayOffset(0.5);
    //$graph->Add($vline);
     
    // ... and display it
    $graph->Stroke();

    Est ce à cause du "for" ????

  7. #7
    Membre actif Avatar de chtipitou
    Profil pro
    Étudiant
    Inscrit en
    Mars 2006
    Messages
    175
    Détails du profil
    Informations personnelles :
    Âge : 37
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mars 2006
    Messages : 175
    Points : 214
    Points
    214
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    var_dump(count($data));
    avant le for tu sera fixé

  8. #8
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Mai 2008
    Messages
    103
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : France, Bas Rhin (Alsace)

    Informations forums :
    Inscription : Mai 2008
    Messages : 103
    Points : 36
    Points
    36
    Par défaut
    Ok bon cela ne change rien. Merci quand même je vais essayer de trouver un autre graph un peu similaire qui marcherait.

  9. #9
    Membre actif Avatar de chtipitou
    Profil pro
    Étudiant
    Inscrit en
    Mars 2006
    Messages
    175
    Détails du profil
    Informations personnelles :
    Âge : 37
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mars 2006
    Messages : 175
    Points : 214
    Points
    214
    Par défaut
    attend c'est normal que ca ne change rien, je cherches juste a savoir la valeur du count.

    donc si tu peux poster la ligne qui a du s'afficher, je pourrai peut etre te dire pourquoi

  10. #10
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Mai 2008
    Messages
    103
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : France, Bas Rhin (Alsace)

    Informations forums :
    Inscription : Mai 2008
    Messages : 103
    Points : 36
    Points
    36
    Par défaut
    Ah pardon excuses moi.
    Rien ne s'affiche du tout.

  11. #11
    Membre actif Avatar de chtipitou
    Profil pro
    Étudiant
    Inscrit en
    Mars 2006
    Messages
    175
    Détails du profil
    Informations personnelles :
    Âge : 37
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mars 2006
    Messages : 175
    Points : 214
    Points
    214
    Par défaut
    ok, si tu l'a bien mis avant le for, c'est embettant, ca veut dire qu'on passe pas par la.

    avant le for
    met

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    echo "var_dump incoming ----------- <br />";
    var_dump(count($data));
    echo "<br />var_dump done ----------- <br />";
     
    exit();

    si la il ya rien qui s'affiche c'est que tu passes pas par la ^^

  12. #12
    Membre actif Avatar de chtipitou
    Profil pro
    Étudiant
    Inscrit en
    Mars 2006
    Messages
    175
    Détails du profil
    Informations personnelles :
    Âge : 37
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mars 2006
    Messages : 175
    Points : 214
    Points
    214
    Par défaut
    c'est normal la difference ici


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    $graph = new GanttGraph(0,0,"auto");
     
     
    et
     
    $graph = new GanttGraph();
    ?

  13. #13
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Mai 2008
    Messages
    103
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : France, Bas Rhin (Alsace)

    Informations forums :
    Inscription : Mai 2008
    Messages : 103
    Points : 36
    Points
    36
    Par défaut
    Ok alors merci pour la technique.
    Je l'ai appliqué à plusieurs endroits du code et je me rends compte que cela vient de plus haut.

    Cela vient d'ici :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     
    $graph->scale->actinfo->SetColTitles(
    			    array('Note','Task','Duration','Start','Finish'),array(20,50,20));
    $graph->scale->actinfo->SetBackgroundColor('green:0.5@0.5');
    $graph->scale->actinfo->SetFont(FF_ARIAL,FS_NORMAL,10);
    $graph->scale->actinfo->vgrid->SetStyle('solid');
    $graph->scale->actinfo->vgrid->SetColor('gray');
    Mais comment se fait-il que lorsque je mets ce même code dans mes bornes <div> (donc premiere page) cela marche et pas maintenant dans cette page de fonction ???

  14. #14
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Mai 2008
    Messages
    103
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : France, Bas Rhin (Alsace)

    Informations forums :
    Inscription : Mai 2008
    Messages : 103
    Points : 36
    Points
    36
    Par défaut
    Non la réponse
    Code :

    $graph = new GanttGraph(0,0,"auto");


    et

    $graph = new GanttGraph();


    ne marche pas

    Merci beaucoup à toi de m'aider autant ..!!

  15. #15
    Membre actif Avatar de chtipitou
    Profil pro
    Étudiant
    Inscrit en
    Mars 2006
    Messages
    175
    Détails du profil
    Informations personnelles :
    Âge : 37
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mars 2006
    Messages : 175
    Points : 214
    Points
    214
    Par défaut
    je vois pas non plus de
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    $graph->scale->actinfo->SetColTitles()
    dans ton 2 eme script

  16. #16
    Membre actif Avatar de chtipitou
    Profil pro
    Étudiant
    Inscrit en
    Mars 2006
    Messages
    175
    Détails du profil
    Informations personnelles :
    Âge : 37
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mars 2006
    Messages : 175
    Points : 214
    Points
    214
    Par défaut
    et t'inquiete pas, je suis au boulot et je me fais ch** ^^

Discussions similaires

  1. Réponses: 4
    Dernier message: 14/09/2012, 08h56
  2. Appel fonction php dans code javascript
    Par licorne dans le forum Général JavaScript
    Réponses: 7
    Dernier message: 05/03/2008, 10h55
  3. Problème avec la taille de mon swf dans une page php
    Par Gizmil dans le forum Dynamique
    Réponses: 2
    Dernier message: 14/10/2007, 21h54
  4. Réponses: 7
    Dernier message: 25/07/2007, 13h14
  5. [Mail] Je ne sais pas dans qu'elle page inserer mon code
    Par bodysplash007 dans le forum Langage
    Réponses: 6
    Dernier message: 19/04/2007, 16h32

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