Bonjour,
J'ai pris un code d'un framework nommé VIS je l'utilise pour avoir un aspect graphique pour des données...
Je voudrais utilisé des données directement d'une base de donnée sans utilisé AJAX ou JSON car c'est trop complexe pour moi j'aimerais utilisé PHP.
Voici le code:
A ce moment là j'ai déjà ce qui me montre dans le graph:
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90 <script src="vis/dist/vis.js"></script> <link href="vis/dist/vis.css" rel="stylesheet" type="text/css" /> <script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','//www.google-analytics.com/analytics.js','ga');ga('create', 'UA-61231638-1', 'auto');ga('send', 'pageview');</script></head> <body> <h2>Mode de calcul et prise d'information (teste)</h2> <h3>L'objectif à attendre dans ce cas est de 70%</h3> <div style="width:50px; font-size:14px; text-align: justify;"> </div> <br /> <div id="visualization"></div> <script type="text/javascript"> // create a dataSet with groups var names = ['SquareShaded', 'Bargraph', 'Blank', 'CircleShaded']; var groups = new vis.DataSet(); groups.add({ id: 0, content: names[0], options: { drawPoints: { style: 'square' // square, circle }, shaded: { orientation: 'bottom' // top, bottom } }}); groups.add({ id: 1, content: names[1], options: { style:'bar' }}); groups.add({ id: 2, content: names[2], options: {drawPoints: false} }); groups.add({ id: 3, content: names[3], options: { drawPoints: { style: 'circle' // square, circle }, shaded: { orientation: 'top' // top, bottom } }}); var container = document.getElementById('visualization'); var items = [ {x: '2014-06-13', y: 60}, {x: '2014-06-14', y: 40}, {x: '2014-06-15', y: 55}, {x: '2014-06-16', y: 40}, {x: '2014-06-17', y: 50}, {x: '2014-06-13', y: 30, group: 0}, {x: '2014-06-14', y: 10, group: 0}, {x: '2014-06-15', y: 15, group: 1}, {x: '2014-06-16', y: 30, group: 1}, {x: '2014-06-17', y: 10, group: 1}, {x: '2014-06-18', y: 15, group: 1}, {x: '2014-06-19', y: 52, group: 1}, {x: '2014-06-20', y: 10, group: 1}, {x: '2014-06-21', y: 20, group: 2}, {x: '2014-06-22', y: 60, group: 2}, {x: '2014-06-23', y: 10, group: 2}, {x: '2014-06-24', y: 25, group: 2}, {x: '2014-06-25', y: 30, group: 2}, {x: '2014-06-26', y: 20, group: 3}, {x: '2014-06-27', y: 60, group: 3}, {x: '2014-06-28', y: 10, group: 3}, {x: '2014-06-29', y: 25, group: 3}, {x: '2014-06-30', y: 30, group: 3} ]; var dataset = new vis.DataSet(items); var options = { defaultGroup: 'ungrouped', legend: true, start: '2014-06-10', end: '2014-07-04' }; var graph2d = new vis.Graph2d(container, dataset, groups, options); </script>
J'ai déjà discuté avec une base de donnée pour d'autre teste et voici le code:
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 var items = [ {x: '2014-06-13', y: 60}, {x: '2014-06-14', y: 40}, {x: '2014-06-15', y: 55}, {x: '2014-06-16', y: 40}, {x: '2014-06-17', y: 50}, {x: '2014-06-13', y: 30, group: 0}, {x: '2014-06-14', y: 10, group: 0}, {x: '2014-06-15', y: 15, group: 1}, {x: '2014-06-16', y: 30, group: 1}, {x: '2014-06-17', y: 10, group: 1}, {x: '2014-06-18', y: 15, group: 1}, {x: '2014-06-19', y: 52, group: 1}, {x: '2014-06-20', y: 10, group: 1}, {x: '2014-06-21', y: 20, group: 2}, {x: '2014-06-22', y: 60, group: 2}, {x: '2014-06-23', y: 10, group: 2}, {x: '2014-06-24', y: 25, group: 2}, {x: '2014-06-25', y: 30, group: 2}, {x: '2014-06-26', y: 20, group: 3}, {x: '2014-06-27', y: 60, group: 3}, {x: '2014-06-28', y: 10, group: 3}, {x: '2014-06-29', y: 25, group: 3}, {x: '2014-06-30', y: 30, group: 3} ];
Bref j'aime utilisé le même while pour qui me donne tout les données sans les BETWEEN bien sûr je voudrais juste affiché de la façon encore plus haut pour que mon graph me montre mes stocks de ma base de donnée.
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 <?php echo $DATE["DATA"]; $servername = "localhost"; $username = "root"; $password = "*****"; $dbname= "CSV_DB"; $EntreeDATE = htmlentities($_POST['EntreeDATE']); $EntreeDATE2 = htmlentities($_POST['EntreeDATE2']); // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("La base de donnée est introuvable " . $conn->connect_error); } $sql = "SELECT DATE, High, Low FROM TBL_NAME WHERE DATE BETWEEN '".$EntreeDATE."' AND '".$EntreeDATE2."'"; // $sql = "SELECT DATE, High, Low FROM TBL_NAME WHERE DATE BETWEEN '".$EntreeDATE."' AND '".$EntreeDATE2."'"; $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { echo "<br> DATE: ". $row["DATE"]. " - High: ". $row["High"]. " - Low " . $row["Low"] . "<br>";
Merci d'avance !
Partager