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

Langage PHP Discussion :

Reproduire une erreur avec jpgraph


Sujet :

Langage PHP

  1. #1
    Membre à l'essai
    Femme Profil pro
    Développeur informatique
    Inscrit en
    Mai 2004
    Messages
    28
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 44
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Santé

    Informations forums :
    Inscription : Mai 2004
    Messages : 28
    Points : 21
    Points
    21
    Par défaut Reproduire une erreur avec jpgraph
    Bonjour,

    J'aimerai reproduire une erreur d'un script, je cherche donc quelques personnes qui voudraient bien tester, s'ils obtiennent également une erreur.

    Les prérequis : PHP7 et jpgraph

    Le script a tester :

    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
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    <?php
    include $_SERVER['DOCUMENT_ROOT'] .'/jpgraph/src/jpgraph.php';
    include $_SERVER['DOCUMENT_ROOT'] .'/jpgraph/src/jpgraph_bar.php';
     
    try{
     
    $bildX=800;
    $bildY=900;
     
    	// Create the graph. These two calls are always required
    	$graph = new Graph($bildX,$bildY,"auto");
            //Added for 4.0
            $graph->ClearTheme();
     
     	$graph->SetScale("textint");
    	// Rotate graph 90 degrees and set margin
     	$graph->Set90AndMargin(160,15,45,40);
     
            $dataCountry = array (
                0 => 'BELGIUM',
                2 => 'FRANCE',
                3 => 'GERMANY'
                );
     
            $dataGender = array (
              0 => 'female',
              1 => 'male');     
     
            $dataCountryColor = array(
                'BELGIUM' => 'dodgerblue4',
                'FRANCE' => 'coral',
                'GERMANY' => 'darkorchid');
     
            $dataCountryGender =array (
      'BELGIUM' =>array ('female' => 1,'male' => 2),
      'FRANCE' => array ('female' => 3,'male' => 4),
      'GERMANY' => array('female' => 5,'male' => 1)
                );
     
     
     
    	// construct the different dataY
    	foreach($dataCountry AS $country){
     
    		foreach($dataGender AS $gender){
     
    			if(empty($dataCountryGender[$country][$gender]))$dataCountryGender[$country][$gender]='';
    			$dataY[$gender][] = $dataCountryGender[$country][$gender];
    			$dataYcolor[$gender][] = $dataCountryColor[$country];
     
    		}
     
    		$dataX[] = $country;
     
    	}
     
            foreach($dataY AS $key => $value){
     
    		$bplot[$key] = new BarPlot($dataY[$key]);
    		$bplot[$key]->SetWidth(1.0);
     
    		# value shown for the bar
    		$bplot[$key]->value->Show();
      		$bplot[$key]->value->SetColor('white');
    		$bplot[$key]->SetValuePos('center');
    		$bplot[$key]->value->SetFormat('%d');
    		$bplot[$key]->value->SetFont(FF_ARIAL,FS_BOLD,10);
     
     
      		$bplot[$key]->SetFillColor($dataYcolor[$key]);
    		switch($key){
    			case 'female':
     		  		$bplot[$key]->SetPattern(PATTERN_CROSS1,'gray');
    			break;
    			case 'male':
    			break;
    			case 'f->m':
    				$bplot[$key]->SetPattern(PATTERN_STRIPE1,'red');	
    			break;
    			case 'm->f':
    				$bplot[$key]->SetPattern(PATTERN_STRIPE2,'black');
    			break;
    			case 'unknown':
    				$bplot[$key]->SetPattern(PATTERN_DIAG1,'gray');
    			break;
    			default:
    				die('error, unknown gender '.$key);
    		}
                    //Error come from here
     
      		$bplot[$key]->SetLegend($key);
     
    		$AccBarPlotArray[] = $bplot[$key];
    	}
     
     
     
    	// Create the grouped bar plot
    	$gbplot = new AccBarPlot($AccBarPlotArray);
     
     
    	// ...and add it to the graPH
    	$graph->Add($gbplot);
     
     
    	// Setup the titles
    	// Setup the titles
    	$graph->title->Set('Nationality 2016');
    	$graph->title->SetMargin(10);
    	$graph->title->SetFont(FF_ARIAL,FS_BOLD,14);
     
     
     
    		$graph->footer->right->Set('imprimé le '.date('d.m.Y') );
    		$graph->footer->right->SetFont(FF_ARIAL,FS_NORMAL,8);
     
     
            $graph->legend->SetFont(FF_ARIAL,FS_NORMAL,15);
    	$graph->legend->SetLineSpacing(7);
    	$graph->legend->SetShadow(FALSE);
     
     
       	$graph->xaxis->SetTickLabels($dataX);
    	$graph->xaxis->SetFont(FF_ARIAL,FS_NORMAL,9);
     
    	$graph->yaxis->SetPos('max');
    	$graph->yaxis->SetLabelSide(SIDE_RIGHT);
    	$graph->yaxis->SetTickSide(SIDE_LEFT);
    	$graph->yaxis->SetLabelMargin(15);
    	$graph->yaxis->scale->SetGrace(5);
     
     
    		$graph->Stroke();
    /*
    include $_SERVER['DOCUMENT_ROOT'] .'/tcpdf/tcpdf_utils.php';        
            
    		$image = $graph->Stroke(_IMG_HANDLER);
    		      
    
    		$pdf= new TCPDF_UTILS();
    		$pdf->AddPage('L','mm','A4');
    
                    $impath=tempnam(sys_get_temp_dir(),'country');
                    imagepng ($image,$impath);
                    $size=getimagesize($impath);
                    $pdf->Image($impath,10,20,260,'','PNG');
                    unlink($impath);
    		imagedestroy($image);
    		$pdf->Output();       
     
     */ 
    }
    catch (Throwable $t){
        var_dump($t);
    }

    Y'a t-il quelques bonnes âmes pour me dire s'ils obtiennent un graphique ou une erreur ?

    Merci d'avance

  2. #2
    Expert éminent sénior
    Avatar de mathieu
    Profil pro
    Inscrit en
    Juin 2003
    Messages
    10 235
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 10 235
    Points : 15 532
    Points
    15 532
    Par défaut
    il y a un avertissement qui se déclenche et qui corrompt la photo
    mais ça a l'air d'être un bug de jpgraph donc vous pouvez cacher cet avertissement (et donc toutes les erreurs) en mettant la ligne suivante juste avant l'appel de "Stroke("

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    ini_set("display_errors", FALSE);
    l'erreur que j'obtiens :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Warning: imagecolorresolvealpha() expects parameter 2 to be long, string given in .../src/jpgraph_rgb.inc.php on line 562
    à cette ligne 562, $r vaut "dodgerblue4" au lieu d'un nombre donc la fonction "imagecolorresolvealpha" râle

  3. #3
    Membre à l'essai
    Femme Profil pro
    Développeur informatique
    Inscrit en
    Mai 2004
    Messages
    28
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 44
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Santé

    Informations forums :
    Inscription : Mai 2004
    Messages : 28
    Points : 21
    Points
    21
    Par défaut
    Merci beaucoup,

    J'ai la même erreur, j'ai envoyé le même script à l'équipe de jpgraph ainsi que la façon dont corriger le bug dans leur code, ils m'ont répondu qu'ils n'arrivaient pas à reproduire l'erreur, du coup je me suis dit que peut-être j'avais un serveur bizarre. Mais je suis rassurée, je ne suis pas la seule !

    Merci beaucoup !

    Éventuellement si d'autres personnes arrivent à la reproduire ?

    Sinon je passerai le sujet en résolu !

  4. #4
    Expert éminent sénior
    Avatar de mathieu
    Profil pro
    Inscrit en
    Juin 2003
    Messages
    10 235
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 10 235
    Points : 15 532
    Points
    15 532
    Par défaut
    pour information, j'ai eu cette erreur avec PHP 5.6.4

Discussions similaires

  1. Une erreur avec saxon8.7
    Par LeNouv_O dans le forum Format d'échange (XML, JSON...)
    Réponses: 2
    Dernier message: 06/02/2007, 13h10
  2. [VB.NET] Pourquoi ai-je une erreur avec GetResponse ?
    Par Arnaud_B dans le forum Services Web
    Réponses: 1
    Dernier message: 25/07/2006, 17h13
  3. [JpGraph] Erreur avec JPGRAPH
    Par voileuxyann dans le forum Bibliothèques et frameworks
    Réponses: 1
    Dernier message: 25/04/2006, 11h13
  4. une erreur avec les pointeur..
    Par lecyberax dans le forum C
    Réponses: 12
    Dernier message: 15/04/2006, 12h04
  5. Réponses: 8
    Dernier message: 20/01/2006, 13h46

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