Merci pour ton aide!!
J'ai essayé ton code en y ajoutant mes données petit à petit.
Ca fonctionne lorsque j'écris les dates:
$sataX = array(2018-03-12,2018-03-13,2018-03-15);
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 <?php // content="text/plain; charset=utf-8" require_once ('jpgraph/src/jpgraph.php'); require_once ('jpgraph/src/jpgraph_line.php'); require_once ('jpgraph/src/jpgraph_date.php'); try { $bdd = new PDO('mysql:host=localhost;dbname=projet;charset=utf8', 'root', ''); } catch(Exception $e) { die('Erreur : '.$e->getMessage()); } /* Fichier permettant la définition des stades de dénutrition */ require 'class/bilan.php'; if(isset($_GET['patient'])) { $infopatient=$bdd->query("SELECT * FROM (patient) WHERE id=".$_GET['patient']); while($donnees=$infopatient->fetch()) { $nom_du_patient=$donnees['nom']; $prenom_du_patient=$donnees['prenom']; $naissance_du_patient=$donnees['date_naissance']; $imc=$donnees['imc']; } $dataY=array(); $dataX=array(); $affichagePatient=$bdd->query("SELECT * FROM patient WHERE nom IN ('".$nom_du_patient."') AND prenom IN('".$prenom_du_patient."') AND date_naissance IN ('".$naissance_du_patient."') ORDER BY date_bilan ASC"); while($donneesPatient=$affichagePatient->fetch()){ $valeur=$donneesPatient['imc']; $date_imc=$donneesPatient['date_bilan']; $dataY[] = $valeur; $dataX=array(2018-03-12,2018-03-13,2018-03-15); } } // Setup the graph $graph = new Graph(900,800); $graph->SetScale("datlin",0,100); $graph->SetMargin(40,40,30,130); $theme_class=new UniversalTheme; $graph->SetTheme($theme_class); $graph->img->SetAntiAliasing(false); $graph->title->Set('Courbes'); // Set the angle for the labels to 90 degrees $graph->xaxis->SetLabelAngle(90); $line = new LinePlot($dataY,$dataX); $line->SetLegend('Year 2005'); $line->SetFillColor('lightblue@0.5'); $graph->Add($line); $graph->Stroke(); // Output line $graph->Stroke(); ?>
Ca bloque quand je récupère mes dates de ma base de données.
$dataX[]=$date_imc;
Pourtant le format est le même que les dates écrites...
Le message d'erreur: either x or y date contains non numericvalues
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 <?php // content="text/plain; charset=utf-8" require_once ('jpgraph/src/jpgraph.php'); require_once ('jpgraph/src/jpgraph_line.php'); require_once ('jpgraph/src/jpgraph_date.php'); try { $bdd = new PDO('mysql:host=localhost;dbname=projet;charset=utf8', 'root', ''); } catch(Exception $e) { die('Erreur : '.$e->getMessage()); } /* Fichier permettant la définition des stades de dénutrition */ require 'class/bilan.php'; if(isset($_GET['patient'])) { $infopatient=$bdd->query("SELECT * FROM (patient) WHERE id=".$_GET['patient']); while($donnees=$infopatient->fetch()) { $nom_du_patient=$donnees['nom']; $prenom_du_patient=$donnees['prenom']; $naissance_du_patient=$donnees['date_naissance']; $imc=$donnees['imc']; } $dataY=array(); $dataX=array(); $affichagePatient=$bdd->query("SELECT * FROM patient WHERE nom IN ('".$nom_du_patient."') AND prenom IN('".$prenom_du_patient."') AND date_naissance IN ('".$naissance_du_patient."') ORDER BY date_bilan ASC"); while($donneesPatient=$affichagePatient->fetch()){ $valeur=$donneesPatient['imc']; $date_imc=$donneesPatient['date_bilan']; $dataY[] = $valeur; $dataX[]=$date_imc; } } // Setup the graph $graph = new Graph(900,800); $graph->SetScale("datlin",0,100); $graph->SetMargin(40,40,30,130); $theme_class=new UniversalTheme; $graph->SetTheme($theme_class); $graph->img->SetAntiAliasing(false); $graph->title->Set('Courbes'); // Set the angle for the labels to 90 degrees $graph->xaxis->SetLabelAngle(90); $line = new LinePlot($dataY,$dataX); $line->SetLegend('Year 2005'); $line->SetFillColor('lightblue@0.5'); $graph->Add($line); $graph->Stroke(); // Output line $graph->Stroke(); ?>
Partager