Legende

Résolu
wiwi1989 Messages postés 10 Date d'inscription   Statut Membre Dernière intervention   -  
jordane45 Messages postés 38486 Date d'inscription   Statut Modérateur Dernière intervention   -
bonjour svp qui peut m'aider à créer légende pour mon histogramme selon la couleur.dja j'ai essayé bcp d'exemple mais ça marche pas et merci bcp

<?php
require_once ('C:\Program Files\EasyPHP-DevServer-14.1VC11\data\localweb\local\src/jpgraph.php');
require_once ('C:\Program Files\EasyPHP-DevServer-14.1VC11\data\localweb\local\src/jpgraph_bar.php');

session_start();
$m = $_SESSION['m1'];
$m2 = $_SESSION['m3'];
$m3 = $_SESSION['m4'];
$m4 = $_SESSION['m5'];
$m5 = $_SESSION['m6'];
$m6 = $_SESSION['m7'];
$m7 = $_SESSION['m8'];
$m8 = $_SESSION['m9'];
$m9 = $_SESSION['m10'];
$m10 = $_SESSION['m11'];
$m11 = $_SESSION['m12'] ;
 
header ("Content-type: image/png");  
// donnees des axes Y et X
$ydata = array($m, $m2, $m3, $m4, $m5, $m6, $m7, $m8, $m9, $m10, $m11);
$xdata = array('C1', 'C2', 'C3', 'C4', 'C5', 'C6','C7','C8','C9','C10','C11');
// creation du graphique
$graph = new Graph(count($ydata)*70, 400);
$graph->SetScale("textint");
// style
$graph->SetShadow();
$graph->SetColor('white');
$graph->SetMarginColor('gray6');
$graph->SetMargin(40, 30, 20, 40);// marge gauche, droite, haut, bas
// donner des titres et etiquettes
$graph->title->Set("Resultat audit organisationnel et physique");
$graph->yaxis->title->Set("moyenne");
$graph->xaxis->title->Set("chapitre");
$graph->xaxis->SetTickLabels($xdata);

// creation histogramme
$hist = new BarPlot($ydata);
$hist->SetWidth(0.6) ;
$hist->SetFillColor(array('#6A455D', '#FD3F92', '#D2CAEC','#00CCCB','#FC5D5D','#6600FF','#FF00FF','#FEE7F0','#048B9A','#DD985C','#25FDE9'));
//$b1plot->SetFillGradient("white",GRAD_LEFT_REFLECTION);
//$hist->SetFillGradient("pink","white", GRAD_MIDVER);
// ajout du composant histogramme au graphique
$graph->Add($hist);
$graph->Add($hist);

// envoi image au format PNG
$graph->img->SetImgFormat("png"); // formats autorises : png, gif, jpg
$graph->Stroke();
?>

  
    
<?php
 
header('Content-type: text/html; charset=UTF-8');
 
?>


EDIT : Ajout des balises de code (la coloration syntaxique).
Explications disponibles ici :
https://codes-sources.commentcamarche.net/faq/10686-le-nouveau-codes-sources-comment-ca-marche#balises-code

Merci d'y penser dans tes prochains messages.
.
A voir également:

1 réponse

jordane45 Messages postés 38486 Date d'inscription   Statut Modérateur Dernière intervention   4 752
 
Bonjour,

Attention dans tes REQUIRE ... tu as un SLASH à la place d'un ANTI-SLASH ... (respecte le même sens partout...)

Ensuite tu nous dis avoir essayé ... mais je ne vois rien dans ton code qui fasse référence à la légende de ton graphique...
Pourrais tu nous montrer le code tenté ??

Sinon voici un exemple de code avec légende :
https://jpgraph.net/features/src/show-example.php?target=new_line1.php

.
0