Bonjour à tous,

Je veux créer des graphes et voici les types de données que j'ai :

- 3.5.5.580
- 8.0.13.912.Wrk
- 5300
- date
- nombre de poste
etc

Et je veux créer avec un graphique x = 3.5.5.580 y = nb 1800.

cette valeur 3.5.5.580 est une version.


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
 
<?php
include ("../jpgraph.php");
include ("../jpgraph_bar.php");
//$db=pg_connect("host=localhost user=postgres password=password") || die ("Connexion impossible");
 
$result = pg_query($db, "SELECT version_moteur, nb_poste FROM version_moteur");
if (!$result)
{
  echo "Une erreur s'est produite.\n";
  exit;
}
 
$tabvm = array();
$nbposte = array();
 
while($row = pg_fetch_assoc($result))
{
  $tabvm[] = 'version_moteur'.$row['version_moteur'];
  $nbposte[] = 'nb_poste'.$row['nb_poste'];
}
// Construction du conteneur
// Spéfication largeur et hauteur
$graph = new Graph(400,250);
 
// Rééntation linére
$graph->SetScale("textlin");
 
// Ajouter une ombre au conteneur
$graph->SetShadow();
 
// Fixer les marges
$graph->img->SetMargin(40,30,25,40);
 
// Créion du graphique histogramme
$bplot = new BarPlot($nbposte);
 
// Spéfication des couleurs des barres
$bplot->SetFillColor(array('red', 'green', 'blue'));
// Une ombre pour chaque barre
$bplot->SetShadow();
 
// Afficher les valeurs pour chaque barre
$bplot->value->Show();
// Fixer l'aspect de la police
$bplot->value->SetFont(FF_ARIAL,FS_NORMAL,9);
// Modifier le rendu de chaque valeur
$bplot->value->SetFormat('%d nb poste');
 
// Ajouter les barres au conteneur
$graph->Add($bplot);
 
// Le titre
$graph->title->Set("Graphique 'HISTOGRAMME' : Indicateurs TED Version moteur");
$graph->title->SetFont(FF_FONT1,FS_BOLD);
 
// Titre pour l'axe horizontal(axe x) et vertical (axe y)
$graph->xaxis->title->Set("version moteur");
$graph->yaxis->title->Set("nombre de poste");
 
$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
 
// Lénde pour l'axe horizontal
$graph->xaxis->SetTickLabels($tabvm);
 
// Afficher le graphique
$graph->Stroke();
 
?>
et voici le message d'erreur :

Either X or Y data arrays contains non-numeric values. Check that the data is really specified as numeric data and not as strings. It is an error to specify data for example as '-2345.2' (using quotes).
Aidez-moi c'est important cordialement,

J'ai même regarder la documentation de Eric.
Puis sur le site du jpgraph qui explique le problème mais ça ne réponds pas à mon problème


"Your data contains non-numeric values."
Most likely Your data really contains non-numeric data which You need to further investigate (for example by printing out the array with a var_dump(). One additional thing to watch out for is if the data looks like ".56" (or "-.56") which is a shortform of "0.56". The problem is that the number starts with an "." (dot) which is non-numeric. The solution is to replace the single dot with a "0."