Bonjour tout le monde,
J'ai un problème pour utiliser la librairie : jpgraph
Ci dessous est mon code:
Et voici l'erreur que j'aie :
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 connect(); $xdata = array(); $ydata = array(); $moi = 59; $today = date('Y-m'); $req = 'SELECT SUM(task_log_hours) as task_log_hours, date_format(task_log_date, "%Y-%m-%d") as mois FROM `task_log` WHERE `task_log_creator` = '.$moi.' AND `task_log_date` LIKE "'.$today.'%" GROUP BY mois'; $res = mysql_query($req); while($row = mysql_fetch_assoc($res)) { $xdata[] = $row['task_log_hours']; $ydata[] = $row['mois']; } close(); // Get the interpolated values by creating // a new Spline object. $spline = new Spline($xdata,$ydata); // For the new data set we want 40 points to // get a smooth curve. list($newx,$newy) = $spline->Get(50); // Create the graph $g = new Graph(300,200); $g->SetMargin(30,20,40,30); $g->title->Set("Natural cubic splines"); //$g->title->SetFont(FF_ARIAL,FS_NORMAL,12); $g->subtitle->Set('(Nombre d\'heures/jour pendant un mois)'); $g->subtitle->SetColor('darkred'); $g->SetMarginColor('lightblue'); //$g->img->SetAntiAliasing(); // We need a linlin scale since we provide both // x and y coordinates for the data points. $g->SetScale('linlin'); // We want 1 decimal for the X-label $g->xaxis->SetLabelFormat('%1.1f'); // We use a scatterplot to illustrate the original // contro points. $splot = new ScatterPlot($ydata,$xdata); // $splot->mark->SetFillColor('red@0.3'); $splot->mark->SetColor('red@0.5'); // And a line plot to stroke the smooth curve we got // from the original control points $lplot = new LinePlot($newy,$newx); $lplot->SetColor('navy'); // Add the plots to the graph and stroke $g->Add($lplot); $g->Add($splot); $g->Stroke();Quelqu'un a une idée ?Invalid input data for spline. Two or more consecutive input X-values are equal. Each input X-value must differ since from a mathematical point of view it must be a one-to-one mapping, i.e. each X-value must correspond to exactly one Y-value.
PS : j'ai les données correctes depuis la BDD. Mais quand je mets des données en dur :ça me donne un graphe.$ydata = array (8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 9, 9, 2 ) ;
$xdata = array ("01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14") ;
Partager