Advertisement
Guest User

Untitled

a guest
Aug 10th, 2016
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.88 KB | None | 0 0
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <title>Temp Chart</title>
  6.  
  7. <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
  8. <style type="text/css">
  9. ${demo.css}
  10. </style>
  11. <script type="text/javascript">
  12. $(function () {
  13. $('#container').highcharts({
  14. chart: {
  15. type: 'spline'
  16. },
  17. title: {
  18. text: 'Temperature at Dag Hammarskjölds Väg, Uppsala'
  19. },
  20. subtitle: {
  21. text: 'by Gortz'
  22. },
  23. xAxis: {
  24. type: 'datetime',
  25. dateTimeLabelFormats: { // don't display the dummy year
  26. hour: '%I %p',
  27. month: '%e. %b',
  28. year: '%b'
  29. },
  30. title: {
  31. text: 'Date'
  32. }
  33. },
  34. yAxis: {
  35. title: {
  36. text: 'degree celsius (°)'
  37. },
  38. min: 0
  39. },
  40. tooltip: {
  41. headerFormat: '<b>{series.name}</b><br>',
  42. pointFormat: '{point.x:%e. %b %I %p}: {point.y:.1f}°'
  43. },
  44.  
  45. plotOptions: {
  46. spline: {
  47. marker: {
  48. enabled: true
  49. }
  50. }
  51. },
  52.  
  53. series: [{
  54. name: 'Inside',
  55. data: [
  56. <?php
  57. $servername = "localhost";
  58. $username = "";
  59. $password = "";
  60. $dbname = "home";
  61.  
  62.  
  63. // Create connection
  64. $conn = new mysqli($servername, $username, $password,$dbname);
  65.  
  66. // Check connection
  67. if ($conn->connect_error) {
  68. die("Connection failed: " . $conn->connect_error);
  69. }
  70. $sql = "SELECT * FROM tempIn";
  71. $result = $conn->query($sql);
  72. $firstRow=1;
  73. if ($result->num_rows > 0) {
  74. while($row = $result->fetch_assoc()) {
  75. if ($firstRow==1){
  76. $firstRow=0;
  77. } else{
  78. echo ",";
  79. }
  80. echo "[Date.UTC(" . date('Y,m,d,H',strtotime($row["timestamp"])) . "),". $row["temperature"] . "]";
  81. }
  82. } else {
  83. echo "0 results";
  84. }
  85. ?>
  86. ]
  87. },{
  88. name: 'Outside',
  89. data: [
  90. <?php
  91. $servername = "localhost";
  92. $username = "";
  93. $password = "";
  94. $dbname = "home";
  95.  
  96.  
  97. // Create connection
  98. $conn = new mysqli($servername, $username, $password,$dbname);
  99.  
  100. // Check connection
  101. if ($conn->connect_error) {
  102. die("Connection failed: " . $conn->connect_error);
  103. }
  104. $sql = "SELECT * FROM tempOut";
  105. $result = $conn->query($sql);
  106. $firstRow=1;
  107. if ($result->num_rows > 0) {
  108. while($row = $result->fetch_assoc()) {
  109. if ($firstRow==1){
  110. $firstRow=0;
  111. } else{
  112. echo ",";
  113. }
  114. echo "[Date.UTC(" . date('Y,m,d,H',strtotime($row["timestamp"])) . "),". $row["temperature"] . "]";
  115. }
  116. } else {
  117. echo "0 results";
  118. }
  119. ?>
  120.  
  121. ]
  122. },]
  123. });
  124. });
  125. </script>
  126. </head>
  127. <body>
  128. <script src="https://code.highcharts.com/highcharts.js"></script>
  129. <script src="https://code.highcharts.com/modules/exporting.js"></script>
  130.  
  131. <div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
  132.  
  133. <script>
  134. $(function () {
  135. $('#container-hum').highcharts({
  136. chart: {
  137. type: 'spline'
  138. },
  139. title: {
  140. text: 'Humidity at Dag Hammarskjölds Väg, Uppsala'
  141. },
  142. subtitle: {
  143. text: 'by Gortz'
  144. },
  145. xAxis: {
  146. type: 'datetime',
  147. dateTimeLabelFormats: { // don't display the dummy year
  148. hour: '%I %p',
  149. month: '%e. %b',
  150. year: '%b'
  151. },
  152. title: {
  153. text: 'Date'
  154. }
  155. },
  156. yAxis: {
  157. title: {
  158. text: 'humidity (%)'
  159. },
  160. min: 0
  161. },
  162. tooltip: {
  163. headerFormat: '<b>{series.name}</b><br>',
  164. pointFormat: '{point.x:%e. %b %I %p}: {point.y:f}%'
  165. },
  166. plotOptions: {
  167. spline: {
  168. marker: {
  169. enabled: true
  170. }
  171. }
  172. },
  173.  
  174. series: [{
  175. name: 'Inside',
  176. data: [
  177. <?php
  178. $servername = "localhost";
  179. $username = "";
  180. $password = "";
  181. $dbname = "home";
  182.  
  183.  
  184. // Create connection
  185. $conn = new mysqli($servername, $username, $password,$dbname);
  186.  
  187. // Check connection
  188. if ($conn->connect_error) {
  189. die("Connection failed: " . $conn->connect_error);
  190. }
  191. $sql = "SELECT * FROM humidityIn";
  192. $result = $conn->query($sql);
  193. $firstRow=1;
  194. if ($result->num_rows > 0) {
  195. while($row = $result->fetch_assoc()) {
  196. if ($firstRow==1){
  197. $firstRow=0;
  198. } else{
  199. echo ",";
  200. }
  201. echo "[Date.UTC(" . date('Y,m,d,H',strtotime($row["timestamp"])) . "),". $row["humidity"] . "]";
  202. }
  203. } else {
  204. echo "0 results";
  205. }
  206. ?>
  207.  
  208. ]
  209. },]
  210. });
  211. });
  212. </script>
  213.  
  214.  
  215.  
  216.  
  217.  
  218. <div id="container-hum" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
  219.  
  220. </body>
  221. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement