Bonjour,
J'utilise Jpgraph pour faire la construction de mes courbes...
Lorsqu'on arrive sur la page, un graphe se génère automatiquement.
Je veux également qu'un autre graphe se fasse lorsque l'utilisateur choisis les données à afficher à l'aide de checkbox...
Donc à chaque fois qu'il coche ou décoche une checkbox la courbe "devrait" changer.
Mais j'ai juste une image "cassé".
Voici mon code qui fait l'appel Ajax :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
 
$.ajax({
		type: "POST",
		url: "req_graphe.php",
		data: "donnees="+req,
		success: function(){
		img = new Image();
		img.src = "req_graphe.php";
		$('#graphe2').html(img);
		}
	});
req est ma requête sql qui fonctionne
voici le code de req_graphe :
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
 
$ma_requete = $_POST['donnees'];
$exe = mysql_query($ma_requete);
$array = mysql_fetch_array($exe);
 
 
$datay1 = array($array[0] ,$array[1], $array[0]);
$datay2 = array($array[0] ,$array[1], $array[0]);
$datay3 = array($array[0] ,$array[1], $array[0]);
 
// Setup the graph
$graph = new Graph(420,226);
$graph->SetScale("textlin");
 
$theme_class= new UniversalTheme;
$graph->SetTheme($theme_class);
 
 
 
$graph->xaxis->SetTickLabels(array('€ initial','€ current','€ final'));
$graph->ygrid->SetFill(false);
 
$p1 = new LinePlot($datay1);
$graph->Add($p1);
 
$p2 = new LinePlot($datay2);
$graph->Add($p2);
 
$p3 = new LinePlot($datay3);
$graph->Add($p3);
 
$p1->SetColor("#01badc");
$p1->SetLegend('Exploitation');
$p1->mark->SetType(MARK_FILLEDCIRCLE,'',1.0);
$p1->mark->SetColor('#01badc');
$p1->mark->SetFillColor('#01badc');
$p1->SetCenter();
$p1->value->Show();
$p1->value->SetFormat('%d');	
$p1->value->SetColor('#01badc');
 
$p2->SetColor("#f23d64");
$p2->SetLegend('Bâtiment');
$p2->mark->SetType(MARK_FILLEDCIRCLE,'',1.0);
$p2->mark->SetColor('#f23d64');
$p2->mark->SetFillColor('#f23d64');
$p2->SetCenter();
$p2->value->Show();
$p2->value->SetFormat('%d');	
$p2->value->SetColor('#f23d64');
 
$p3->SetColor("#ffa800");
$p3->SetLegend('Infrastructure');
$p3->mark->SetType(MARK_FILLEDCIRCLE,'',1.0);
$p3->mark->SetColor('#ffa800');
$p3->mark->SetFillColor('#ffa800');
$p3->SetCenter();
$p3->value->Show();
$p3->value->SetFormat('%d');	
$p3->value->SetColor('#ffa800');
 
$graph->legend->SetFrameWeight(1);
$graph->legend->SetColor('#4E4E4E','#00A78A');
$graph->legend->SetMarkAbsSize(8);
 
// Output line
echo $graph->Stroke();
Mais malheureusement il ne s'affiche pas
pourtant quand je met
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
 
echo $graph->Stroke('images/test_graph.png');
Je génère bien mon graphe, donc je pense que ca vient de l'ajax...
merci de votre aide