Salut,
Je n'arrive pas à faire un graphique. Je récupère les données d'une base MySQL, mais lorsque j'insère l'image j'ai une petite croix rouge.......![]()
![]()
Voici mon code fichier niveau_courbe1.php :
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 $sql_compteur ="Requête qui fonctionne"; $result_compteur=mysql_query($sql_compteur); $row_compteur = mysql_fetch_array($result_compteur); $compteur = $row_compteur['nb']; $a=1; $sql_x = "Requête qui fonctionne"; $result_x=mysql_query($sql_x); $x1 = array(); while ($row_x = mysql_fetch_array($result_x)){ if ($a==$compteur){ $x1[] = $row_x['nb'];} else { $x1[] = $row_x['nb'].", "; $a = $a + 1;} } $a=1; $sql_y = "Requête qui fonctionne"; $result_y=mysql_query($sql_y); $y1 = array(); while ($row_y = mysql_fetch_array($result_y)){ if ($a==$compteur){ $y1[] = "'".$row_y['libelle']."'";} else { $y1[] = "'".$row_y['libelle']."', "; $a = $a + 1;} } print_r($x1); echo "<br>"; print_r($y1); echo "<br>"; echo "<br><img src=\"niveau_courbe2.php?x1=".urlencode(serialize($x1))."&x2=".urlencode(serialize($y1))."\">";
Et mon code fichier niveau_courbe2.php :
Voici une variante du fichier niveau_courbe1.php qui ne donne pas plus de résultat :
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 <?php if(isset($_GET['x1'])===FALSE){exit;} if(isset($_GET['y1'])===FALSE){exit;} $x = @unserialize($_GET['x1']); $y = @unserialize($_GET['y1']); if(is_array($x)===FALSE){exit;} if(is_array($y)===FALSE){exit;} require_once "../../../Artichow/BarPlot.class.php"; $graph = new Graph(800, 400); $graph->setAntiAliasing(TRUE); $plot = new BarPlot($x); $plot->setSpace(4, 4, 10, 0); $plot->setPadding(40, 15, 10, 40); $plot->title->set("Niveau 4"); $plot->title->setFont(new TuffyBold(11)); //$plot->title->border->show(); $plot->title->setBackgroundColor(new Color(255, 255, 255, 25)); $plot->title->setPadding(4, 4, 4, 4); $plot->title->move(-20, 25); $plot->yAxis->title->set("Nombre"); $plot->yAxis->title->setFont(new TuffyBold(10)); $plot->yAxis->title->move(-4, 0); $plot->yAxis->setTitleAlignment(Label::TOP); $plot->xAxis->title->set("Incident"); $plot->xAxis->title->setFont(new TuffyBold(10)); $plot->xAxis->setTitleAlignment(Label::RIGHT); $plot->setBackgroundGradient( new LinearGradient( new Color(230, 230, 230), new Color(255, 255, 255), 0 ) ); $plot->barBorder->setColor(new Color(0, 0, 150, 20)); $plot->setBarGradient( new LinearGradient( new Color(150, 150, 210, 0), new Color(230, 230, 255, 30), 0 ) ); $plot->xAxis->setLabelText($y); $plot->xAxis->label->setFont(new TuffyBold(7)); $graph->shadow->setSize(4); $graph->shadow->setPosition(Shadow::LEFT_TOP); $graph->shadow->smooth(TRUE); $graph->shadow->setColor(new Color(160, 160, 160)); $graph->add($plot); $graph->draw(); ?>
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 $sql_x = "Requête qui fonctionne"; $result_x=mysql_query($sql_x); $x1 = array(); while ($row_x = mysql_fetch_array($result_x)){ $x1[] = $row_x['nb'];} $sql_y = "Requête qui fonctionne"; $result_y=mysql_query($sql_y); $y1 = array(); while ($row_y = mysql_fetch_array($result_y)){ $y1[] = "'".$row_y['libelle']."'";} print_r($x1); echo "<br>"; print_r($y1); echo "<br>"; echo "<br><img src=\"niveau_courbe2.php?x1=".urlencode(serialize($x1))."&x2=".urlencode(serialize($y1))."\">";
Partager