GWibisono

harusnya gini kk disesuaikan dgn kebutuhan

Feb 2nd, 2016
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.53 KB | None | 0 0
  1. <?php
  2. $server = "localhost";
  3. $username = "root";
  4. $password = "";
  5. $database = "rs.paru";
  6. mysql_connect($server,$username,$password) or die("Koneksi gagal");
  7. mysql_select_db($database) or die("Database tidak bisa dibuka");
  8. $sql   = "SELECT count(*) c, jeniskelaminPasien from pasien group by jeniskelaminPasien";
  9. $query = mysql_query( $sql )  or die(mysql_error());
  10. $data=array();      
  11. while($ambil = mysql_fetch_array($query)){
  12.    $data[ $ambil['jeniskelaminPasien'] ]=$ambil['c'];          
  13. }
  14.  
  15. ?><meta http-equiv="content-type" content="text/html; charset=utf-8" />
  16. <title>Grafik Penduduk Indonesia</title>
  17. <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
  18. <script src="http://code.highcharts.com/highcharts.js"></script>
  19. <script src="http://code.highcharts.com/modules/exporting.js"></script>
  20. <script type="text/javascript">
  21.   var chart1; // globally available
  22. $(document).ready(function() {
  23.      $('#container').highcharts({
  24.         chart: {
  25.             type: 'column'
  26.         },
  27.         title: {
  28.             text: 'Data Pasien Menurut Jenis Kelamin'
  29.         },
  30.         subtitle: {
  31.             text: 'Source: <a href="https://m.facebook.com/groups/35688476100?view=permalink&id=10153820258681101&refid=18&_ft_=qid.6246879918428680191%3Amf_story_key.10153820258681101%3Atl_objid.10153820258681101">php group</a>'
  32.         },
  33.         xAxis: {
  34.             type: 'category',
  35.             labels: {
  36.                 rotation: -45,
  37.                 style: {
  38.                     fontSize: '13px',
  39.                     fontFamily: 'Verdana, sans-serif'
  40.                 }
  41.             }
  42.         },
  43.         yAxis: {
  44.             min: 0,
  45.             title: {
  46.                 text: 'Jumlah Pasien'
  47.             }
  48.         },
  49.         legend: {
  50.             enabled: true
  51.         },
  52.         tooltip: {
  53.             pointFormat: 'jumlah : <b>{point.y:.1f} Ribu </b>'
  54.         },
  55.         series: [{
  56.             name: 'Kelamin',
  57.             data: [
  58. <?php
  59. foreach($data as $key=>$val){
  60.     printf("\n['%s',%f],", $key,$val);
  61. }
  62. ?>    
  63.             ],
  64.             dataLabels: {
  65.                 enabled: true,
  66.                 rotation: -90,
  67.                 color: '#FFFFFF',
  68.                 align: 'right',
  69.                 format: '{point.y:.1f}', // one decimal
  70.                 y: 10, // 10 pixels down from the top
  71.                 style: {
  72.                     fontSize: '13px',
  73.                     fontFamily: 'Verdana, sans-serif'
  74.                 }
  75.             }
  76.         }]
  77.     });
  78.  
  79. ///======================
  80. });
  81. </script>
Advertisement
Add Comment
Please, Sign In to add comment