Advertisement
Guest User

Untitled

a guest
Mar 29th, 2015
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.25 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>Highcharts</title>
  6. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
  7. <script type="text/javascript">
  8. $(document).ready(function() {
  9. var options = {
  10. chart: {
  11. renderTo: 'container',
  12. type: 'line',
  13. marginRight: 130,
  14. marginBottom: 25
  15. },
  16. title: {
  17. text: 'San luong Card',
  18. x: -20 //center
  19. },
  20. subtitle: {
  21. text: '',
  22. x: -20
  23. },
  24. xAxis: {
  25. categories: []
  26. },
  27. yAxis: {
  28. title: {
  29. text: 'Tong tien'
  30. },
  31. plotLines: [{
  32. value: 0,
  33. width: 1,
  34. color: '#red'
  35. }]
  36. },
  37. tooltip: {
  38. formatter: function() {
  39. return '<b>'+ this.series.name +'</b><br/>'+
  40. this.x +': '+ this.y;
  41. }
  42. },
  43. legend: {
  44. layout: 'vertical',
  45. align: 'right',
  46. verticalAlign: 'top',
  47. x: -10,
  48. y: 100,
  49. borderWidth: 0
  50. },
  51. plotOptions: {
  52. area: {
  53. stacking: 'high',
  54. lineColor: '#666666',
  55. lineWidth: 1,
  56. marker: {
  57. lineWidth: 1,
  58. lineColor: '#666666'
  59. }
  60. }
  61. },
  62. series: []
  63. }
  64.  
  65.  
  66.  
  67.  
  68. $.getJSON("data.php", function(json) {
  69. options.xAxis.categories = json[0]['data'];
  70. options.series[0] = json[1];
  71. var chart = new Highcharts.Chart(options);
  72. return false;
  73. })
  74.  
  75. });
  76. </script>
  77. <script src="http://code.highcharts.com/highcharts.js"></script>
  78. <script src="http://code.highcharts.com/modules/exporting.js"></script>
  79. </head>
  80. <body>
  81. <form method="post" action="data.php" id="form_search">
  82. <header><h3>Thong ke CCU</h3></header>
  83. <div class="module_content">
  84. <fieldset>
  85. <label>Tu ngay</label>
  86. <input type="text" name="t_n" />
  87. </fieldset>
  88. <fieldset>
  89. <label>Den ngay</label>
  90. <input type="text" name="d_n" />
  91. </fieldset>
  92. <div class="clear"></div>
  93. </div>
  94. <footer>
  95. <div class="submit_link">
  96. <input type="submit" name="s_t" value="Search" id="submit" class="alt_btn">
  97. <input type="reset" name="reset" value="Refesh" >
  98. </div>
  99.  
  100. </form>
  101. <div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
  102. </body>
  103. </html>
  104.  
  105. if(isset($_POST['s_t'])){
  106. include("../config/dbconnect.php");
  107. $date = new DateTime();
  108. $t_n = strtotime($_POST['t_n']);
  109. $d_n = strtotime($_POST['d_n']);
  110. $tn = date("Y-m-d",$t_n);
  111. $dn = date("Y-m-d",$d_n);
  112. $querry = mysql_query("select SUM(ccu) as sumccu,DATE_FORMAT(date,'%d-%m') as day from skycity_log.ccu_log where date >='".$tn."' AND date <='".$dn."' GROUP BY date") or (mysql_error());
  113.  
  114. $category = array();
  115. $category['name'] = 'DAY';
  116.  
  117. $series1 = array();
  118. $series1['name'] = 'CCU';
  119.  
  120. while($r = mysql_fetch_array($querry)) {
  121. echo $r['day'];
  122. $category['data'][] = $r['day'];
  123. $series1['data'][] = $r['sumccu'];
  124.  
  125. }
  126.  
  127. $result = array();
  128. array_push($result,$category);
  129. array_push($result,$series1);
  130.  
  131.  
  132. print json_encode($result, JSON_NUMERIC_CHECK);
  133. }
  134.  
  135. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement