Bonjour a tous.
J'ai un formulaire qui envoi une varaible a un script pour creer un graphique.
Lorsque j'utilise le script exemple de JPGRAPH, je graphique s'affiche correctement.
Quand j'intègre le scrip exemple dans mon script, c est un carre blanc qui s'affiche.
La requete renvoi bien les données de la BDD.
print_r(array_values($ydata));
Array ( [0] => 10 [1] => 40 [2] => 5 [3] => 5 [4] => 20 [5] => 91 ) qui est parfaitement correct avec la BD.
Merci par avance pour votre aide
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 <?php //Démarrage des sessions session_start (); //Affichage des erreurs PHP error_reporting(E_ALL); ini_set('display-errors','on'); // REQUIRE require_once ('jpgraph/src/jpgraph.php'); require_once ('jpgraph/src/jpgraph_line.php'); require_once ('connexion.php'); //Récupération PROPRE des variables AVANT de les utiliser $mes_opcion = !empty($_POST['mes']) ? $_POST['mes'] : (!empty($_SESSION['mes']) ? $_SESSION['mes'] : NULL); $_SESSION['mes'] = $mes_opcion ; //Traitement $sql = 'SELECT fecha, lluvia FROM meteo WHERE MONTH(fecha) = ? '; $datas = array($mes_opcion[0]); try{ $req = $connexion->prepare($sql); $req->execute($datas); $row = $req->fetchAll(PDO::FETCH_ASSOC); //on stocke les données dans un ARRAY }catch(Exception $e){ echo "Erreur ! ".$e->getMessage(); } $ydata = array(); //$xdata = array(); if(!empty($row)){ $index=1; foreach($row as $R) { $ydata[$index] = intval($R['lluvia']); //$xdata[$index] = $R['fecha']; $index ++; } }else{ echo " La requête n'a pas retournée de données.... "; print_r($datas); exit(); } $req->closeCursor(); //$ydata = array(11, 3, 8, 12, 5, 1, 9, 13, 5, 7); ?> <!DOCTYPE> <html> <head> <meta http-equiv="Content-Type" content="text/html" /> <meta charset="UTF-8"> <link rel="stylesheet" href="general.css" type="text/css" media="screen"/> <link rel="stylesheet" href="print.css" type="text/css" media="print" /> <style type="text/css" media="all"> </style> </head> <body> <div id="graphique"> <?php // Size of the overall graph $width=350; $height=250; // Create the graph and set a scale. // These two calls are always required $graph = new Graph($width,$height); $graph->SetScale('intlin'); $graph->SetShadow(); $graph->img->SetAntiAliasing(); // Setup margin and titles $graph->SetMargin(40,20,20,40); $graph->title->Set('Calls per operator (June,July)'); $graph->subtitle->Set('(March 12, 2008)'); $graph->xaxis->title->Set('Operator'); $graph->yaxis->title->Set('# of calls'); $graph->yaxis->title->SetFont( FF_FONT1 , FS_BOLD ); $graph->xaxis->title->SetFont( FF_FONT1 , FS_BOLD ); // Create the first data series $lineplot=new LinePlot($ydata); $lineplot->SetWeight(2); // Two pixel wide // Add the plot to the graph $graph->Add($lineplot); // Display the graph $graph->Stroke(); ?> </div> </body> </html>
Partager