Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.03 KB | None | 0 0
  1. <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
  2. <script src="http://code.highcharts.com/highcharts.js"></script>
  3. <script src="http://code.highcharts.com/modules/exporting.js"></script>
  4. <script src="http://code.highcharts.com/themes/gray.js"></script>
  5.  
  6. <script type="text/javascript">
  7. var chart;
  8. $(document).ready(function() {
  9. var options = {
  10. chart: {
  11. renderTo: 'container1',
  12. defaultSeriesType: 'area',
  13. marginRight: 10,
  14. marginBottom: 25,
  15. zoomType: 'xy' //zoom
  16. },
  17. credits: {
  18. enabled: false
  19. },
  20.  
  21. title: {
  22. text: 'Temperature',
  23. x: -20 //center
  24. },
  25. subtitle: {
  26. text: '',
  27. x: -20
  28. },
  29. xAxis: {
  30. type: 'datetime',
  31. //tickInterval: 4 * 24 * 3600 * 1000 , // one hour
  32. //minRange: 14 * 24 * 3600000,
  33. minRange: 4 * 24 * 3600 * 1000,
  34. tickWidth: 0,
  35. gridLineWidth: 2,
  36. /*labels: {
  37. align: 'center',
  38. x: -3,
  39. y: 20,
  40. formatter: function() {
  41. return Highcharts.dateFormat('%b %e', this.value);
  42. }
  43. }*/
  44. },
  45. yAxis: {
  46. title: {
  47. text: 'Temperature °C',
  48. lineColor: '#FF0000',
  49. lineWidth: 1,
  50.  
  51.  
  52. },
  53. min: null, // Will for min and max to adjust when you zoom
  54. max: null, //
  55. startOnTick: false,
  56. minTickInterval: 1,
  57. showFirstLabel: false
  58.  
  59. /*plotLines: [{
  60. value: 0,
  61. width: 0,
  62. color: 'green'
  63. }]*/
  64. },
  65. tooltip: {
  66. valueDecimals: 2
  67. //formatter: function() {
  68. // return Highcharts.dateFormat('%b %e', this.x-(1000*3600)) +'-'+ Highcharts.dateFormat('%l%p', this.x) +': <b>'+ this.y + '</b>';
  69. //}
  70.  
  71. },
  72.  
  73.  
  74. legend: {
  75. layout: 'vertical',
  76. align: 'right',
  77. verticalAlign: 'top',
  78. x: -10,
  79. y: 100,
  80. borderWidth: 0
  81. },
  82.  
  83. plotOptions: {
  84. series: {
  85. marker: {
  86. radius: 1
  87. }
  88. }
  89. },
  90.  
  91. series : [{
  92. type: 'area',
  93. name : 'Temperature °C',
  94. color: '#0099FF',
  95. fillOpacity: 0.3,
  96. showInLegend: false,
  97.  
  98.  
  99. }]
  100. }
  101. // Load data asynchronously using jQuery. On success, add the data
  102. // to the options and initiate the chart.
  103. // This data is obtained by exporting a GA custom report to TSV.
  104. // http://api.jquery.com/jQuery.get/
  105. jQuery.get('php_scripts/data.php', null, function(tsv) {
  106. var lines = [];
  107. traffic = [];
  108. try {
  109. // split the data return into lines and parse them
  110. tsv = tsv.split(/n/g);
  111. jQuery.each(tsv, function(i, line) {
  112. line = line.split(/,/);
  113. date = Date.parse(line[0] +' UTC');
  114. traffic.push([
  115. date,
  116. parseInt(line[4].replace(',', ''), 10)
  117. ]);
  118. });
  119. } catch (e) { }
  120. options.series[0].data = traffic;
  121. chart = new Highcharts.Chart(options);
  122. });
  123. });
  124.  
  125. <td><div id="container1" style="width: 725px; height: 300px;"></div></td>
  126.  
  127. <?php
  128. $con = mysql_connect("db4free.net","username","password");
  129.  
  130. if (!$con) {
  131. die('Could not connect: ' . mysql_error());
  132. }
  133.  
  134. mysql_select_db("weatherlog", $con);
  135.  
  136. $result = mysql_query("SELECT * FROM weatherlog");
  137.  
  138. while($row = mysql_fetch_array($result)) {
  139.  
  140. echo $row['TIME'] . " , " . $row['TEMP']. " , " . $row['HUMIDITY'] . " , " . $row['PRESSURE'] . " , " . $row['OUTTEMP'] . " , " . $row['OUTHUMIDITY'] . " , " . $row['RAIN'] . " , " . $row['WINDSPEED'] . "n";
  141.  
  142. }
  143.  
  144. mysql_close($con);
  145. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement