Guest User

Untitled

a guest
Oct 13th, 2016
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>high chart</title>
  5. <script type="text/javascript" src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
  6. <script type="text/javascript" src="http://code.highcharts.com/highcharts.js"></script>
  7. <script type="text/javascript" src="http://code.highcharts.com/modules/exporting.js"></script>
  8. <style type="text/css">
  9. .container { margin: auto; padding: 5px; width: 800px; border: 2px solid #DBDBDB; }
  10. </style>
  11. </head>
  12. <body>
  13. <div class="container">
  14. <div class="grafik" style="width:100%; height:400px;"></div>
  15. </div>
  16.  
  17. <?php
  18. // koneksi ke database
  19. $host = 'localhost';
  20. $user = 'root';
  21. $pass = 'root';
  22. $db = 'mydb';
  23. mysql_select_db($db, mysql_connect($host, $user, $pass));
  24.  
  25. //data array
  26. $array_series=array();
  27. $array_categories = array();
  28.  
  29.  
  30. $sql = 'SELECT * FROM revenue';
  31. $rs = mysql_query($sql);
  32.  
  33. while($row = mysql_fetch_array($rs)) {
  34. $date = $row['trx_date'];
  35. $revenue = $row['total_revenue'];
  36.  
  37. array_push($array_series, array('date'=>$date, 'revenue'=>$revenue));
  38.  
  39. array_push($array_categories, $date);
  40. }
  41. ?>
  42.  
  43. <script type="text/javascript">
  44. $('.grafik').highcharts({
  45. chart: {
  46. type: 'column',
  47. marginTop: 80
  48. },
  49. credits: {
  50. enabled: false
  51. },
  52. tooltip: {
  53. shared: true,
  54. crosshairs: true,
  55. headerFormat: '<b>{point.key}</b>< br />'
  56. },
  57. title: {
  58. text: 'REVENUE'
  59. },
  60. subtitle: {
  61. text: 'Bulan Januari'
  62. },
  63. xAxis: {
  64. categories: <?php echo json_encode($array_categories); ?>,
  65. labels: {
  66. rotation: 0,
  67. align: 'right',
  68. style: {
  69. fontSize: '10px',
  70. fontFamily: 'Verdana, sans-serif'
  71. }
  72. }
  73. },
  74. legend: {
  75. enabled: true
  76. },
  77. series: <?php echo json_encode($array_series); ?>
  78.  
  79. });
  80. </script>
  81.  
  82. </body>
  83. </html>
Add Comment
Please, Sign In to add comment