aries_

grafik_

Jun 26th, 2012
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.29 KB | None | 0 0
  1. <?php
  2. include 'config/konek.php';
  3. echo " <font color=#000>
  4.    <b>Filter Tanggal Berdasarkan ";
  5. echo "<form method=POST action=?module=graph>
  6.    Tanggal Mulai : <input type='text' name='tanggal' size='10'>
  7.    Tanggal Akhir : </b><input type='text' name='tanggal_2' size='10'>
  8.     <input type='submit' name='cari' value='Cari'>
  9.     </form><br>";
  10.      
  11. $query = "select count(*) as Berhasil from plan where Terlaksana = 'Berhasil'";
  12. $hasil = mysql_query($query);
  13. $data  = mysql_fetch_array($hasil);
  14. $Berhasil= $data['Berhasil'];
  15.  
  16. // mencari jumlah kegagalan dari database
  17. $query = "select count(*) as Gagal from plan where Terlaksana != 'Berhasil'";
  18. $hasil = mysql_query($query);
  19. $data  = mysql_fetch_array($hasil);
  20. $Gagal = $data['Gagal'];
  21.  
  22. // menghitung total training
  23. $total = $Berhasil+ $Gagal;
  24.  
  25. // menghitung presentase berhasil dan gagal
  26. if ($total == 0) {
  27.     echo "Tidak ada Pelatihan yang terjadi";
  28. }else {
  29. $keberhasilan = $Berhasil/$total * 100;
  30. $kegagalan = $Gagal/$total * 100;
  31. }
  32.  
  33. ?>
  34. <html>
  35.     <head>
  36.         <!-- 1. Add these JavaScript inclusions in the head of your page -->
  37.         <script type="text/javascript" src="js/jquery.min.js"></script>
  38.         <script type="text/javascript" src="js/highcharts.js"></script>
  39.        
  40.         <!-- 1a) Optional: add a theme file -->
  41.         <!--
  42.             <script type="text/javascript" src="../js/themes/gray.js"></script>
  43.         -->
  44.        
  45.         <!-- 1b) Optional: the exporting module -->
  46.         <script type="text/javascript" src="js/modules/exporting.js"></script>
  47.        
  48.        
  49.         <!-- 2. Add the JavaScript to initialize the chart on document ready -->
  50.         <script type="text/javascript">
  51.        
  52.             var chart;
  53.             $(document).ready(function() {
  54.                 chart = new Highcharts.Chart({
  55.                     chart: {
  56.                         renderTo: 'container',
  57.                         zoomType: 'xy'
  58.                     },
  59.                     title: {
  60.                         text: 'Laporan Grafik pelatihan'
  61.                     },
  62.                     subtitle: {
  63.                         text: 'LMC'
  64.                     },
  65.                     xAxis: [{
  66.                         categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
  67.                             'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
  68.                     }],
  69.                     yAxis: [{
  70.                         labels: {
  71.                             formatter: function() {
  72.                                 return this.value +'';
  73.                             },
  74.                             style: {
  75.                                 color: '#6cb3ea'
  76.                             }
  77.                         },
  78.                         title: {
  79.                             text: 'Persentase training(%)',
  80.                             style: {
  81.                                 color: '#6cb3ea'
  82.                             }
  83.                         }
  84.                     }],
  85.                     tooltip: {
  86.                         formatter: function() {
  87.                             return ''+
  88.                                 this.x +': '+ this.y +
  89.                                 (this.series.name == 'Presentase' ? '' : '%');
  90.                         }
  91.                     },
  92.                     legend: {
  93.                         layout: 'vertical',
  94.                         align: 'left',
  95.                         x: 100,
  96.                         verticalAlign: 'top',
  97.                         y: 100,
  98.                         floating: true,
  99.                         backgroundColor: '#FFFFFF'
  100.                     },
  101.                     series: [{
  102.                         name: 'Berhasil Dilaksanakan',
  103.                         color: '#4572A7',
  104.                         type: 'column',
  105.                         data: [<?php echo $keberhasilan;?>]    
  106.                    
  107.                     }, {
  108.                         name: 'Gagal Dilaksanakan',
  109.                         color: '#eaff00',
  110.                         type: 'column',
  111.                         data: [<?php echo $kegagalan;?>]
  112.                     }]
  113.                 });
  114.                
  115.                
  116.             });
  117.                
  118.         </script>
  119.         </script>
  120.     </head>
  121.     <body>
  122. <script src="js/highcharts.js"></script>
  123. <script src="js/modules/exporting.js"></script>
  124.  
  125. <div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
  126.  
  127.     </body>
  128. </html>
  129. <?php
  130.  
  131. echo "<b> <h3> Jumlah Pelatihan saat ini : $total pelatihan</h3></b>";
  132. ?>
Advertisement
Add Comment
Please, Sign In to add comment