| 12
 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
 
 | <?php   
include ("./src/jpgraph.php"); // Bibliotheque necessaire au type de graph
include ("./src/jpgraph_bar.php");
 
// Definition des Users , pass, bdd ...
define('MYSQL_HOST', 'localhost'); 
define('MYSQL_USER', 'root'); 
define('MYSQL_PASS', ''); 
define('MYSQL_DATABASE', 'BaseNotesIris');   
 
//$tableauMati = array(); 
$tableauNotes = array();   // Création d'un tableau de notes
 
// ************************************************************************ 
// Extraction des données dans la base de données ************************* 
// ************************************************************************   
 
// Selection des differents champs souhaités de  la bdd
$sql = <<<EOF
	SELECT  
		Francais,
		Anglais,
		Economie  ,
		Math      ,
		Physique  ,
		Informatique1 ,
		Informatique2 ,
		Informatique3 ,
		Informatique4 
	FROM `annee1`
EOF;
 
// Requetes sql
$mysqlCnx = @mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS) or die('Pb de connxion mysql');   
@mysql_select_db(MYSQL_DATABASE) or die('Pb de selection de la base');   
$mysqlQuery = @mysql_query($sql, $mysqlCnx) or die('Pb de requête');   
 
// Scan de la base de donnée en affectant les données dans le tableau
while ($row = mysql_fetch_array($mysqlQuery, MYSQL_ASSOC)) 
{  
	$tableauNotes[] = $row['Francais']; 
	$tableauNotes[] = $row['Anglais']; 
	$tableauNotes[] = $row['Economie']; 
	$tableauNotes[] = $row['Math']; 
	$tableauNotes[] = $row['Physique']; 
	$tableauNotes[] = $row['Informatique1']; 
	$tableauNotes[] = $row['Informatique2']; 
	$tableauNotes[] = $row['Informatique3']; 
	$tableauNotes[] = $row['Informatique4']; 
} 
 
// ************************************************************************
// *************************Création du graph *******************************
// ************************************************************************
 
// Notes en datay et Matieres en datax 
// En data X on ecrit les titres car on veut les notes en fonction des matieres !  Si on voulait des notes en fonction du num de trimestre il faudrait creer un nouveau tableau et effectuer la meme manip que pour tableauNotes !!!
$datax=array("Français ","Anglais ","Economie ","Mathématiques ","Physique ","Informatique1 ","Informatique2 ","Informatique3 ","Informatique4 ");
$datay=$tableauNotes;
 
// Size of graph
$width=500; 
$height=500;
 
// Set the basic parameters of the graph 
$graph = new Graph($width,$height,'auto');
$graph->SetScale("textlin");
 
$top = 50;
$bottom = 80;
$left = 50;
$right = 40;
$graph->Set90AndMargin('auto',$right,$top,$bottom);
 
$graph->xaxis->SetPos('min');
 
// Nice shadow
$graph->SetShadow();
 
// Setup title
$graph->title->Set("Notes du premier trimestre");
//$graph->title->SetFont(FF_VERDANA,FS_BOLD,14);
$graph->subtitle->Set("(DURAND Adrien)");
 
// Setup X-axis
$graph->xaxis->SetTickLabels($datax);
//$graph->xaxis->SetFont(FF_FONT2,FS_BOLD,12);
 
// Some extra margin looks nicer
$graph->xaxis->SetLabelMargin(1);
 
// Label align for X-axis
$graph->xaxis->SetLabelAlign('right','center');
 
// Add some grace to y-axis so the bars doesn't go
// all the way to the end of the plot area
$graph->yaxis->scale->SetGrace(20);
 
// Setup the Y-axis to be displayed in the bottom of the 
// graph. We also finetune the exact layout of the title,
// ticks and labels to make them look nice.
$graph->yaxis->SetPos('max');
 
// First make the labels look right
$graph->yaxis->SetLabelAlign('center','top');
$graph->yaxis->SetLabelFormat('%d');
$graph->yaxis->SetLabelSide(SIDE_RIGHT);
 
// The fix the tick marks
$graph->yaxis->SetTickSide(SIDE_LEFT);
 
// Finally setup the title
$graph->yaxis->SetTitleSide(SIDE_RIGHT);
$graph->yaxis->SetTitleMargin(35);
 
// To align the title to the right use :
$graph->yaxis->SetTitle('Bts IRIS 2006/2007','high');
$graph->yaxis->title->Align('right');
 
// To center the title use :
//$graph->yaxis->SetTitle('Turnaround 2002','center');
//$graph->yaxis->title->Align('center');
 
//$graph->yaxis->title->SetFont(FF_ARIAL,FS_BOLD,12);
$graph->yaxis->title->SetAngle(0);
 
$graph->yaxis->SetFont(FF_FONT2,FS_NORMAL);
// If you want the labels at an angle other than 0 or 90
// you need to use TTF fonts
//$graph->yaxis->SetLabelAngle(0);
 
// Now create a bar pot
$bplot = new BarPlot($datay);
$bplot->SetFillColor("orange");
$bplot->SetShadow();
 
//You can change the width of the bars if you like
//$bplot->SetWidth(0.5);
 
// We want to display the value of each bar at the top
$bplot->value->Show();
//$bplot->value->SetFont(FF_ARIAL,FS_BOLD,12);
$bplot->value->SetAlign('left','center');
$bplot->value->SetColor("black","darkred");
$bplot->value->SetFormat('%.1f /20');
 
// Add the bar to the graph
$graph->Add($bplot);
 
$graph->Stroke();
?> | 
Partager