Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $server = "localhost";
- $username = "root";
- $password = "";
- $database = "rs.paru";
- mysql_connect($server,$username,$password) or die("Koneksi gagal");
- mysql_select_db($database) or die("Database tidak bisa dibuka");
- $sql = "SELECT count(*) c, jeniskelaminPasien from pasien group by jeniskelaminPasien";
- $query = mysql_query( $sql ) or die(mysql_error());
- $data=array();
- while($ambil = mysql_fetch_array($query)){
- $data[ $ambil['jeniskelaminPasien'] ]=$ambil['c'];
- }
- ?><meta http-equiv="content-type" content="text/html; charset=utf-8" />
- <title>Grafik Penduduk Indonesia</title>
- <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
- <script src="http://code.highcharts.com/highcharts.js"></script>
- <script src="http://code.highcharts.com/modules/exporting.js"></script>
- <script type="text/javascript">
- var chart1; // globally available
- $(document).ready(function() {
- $('#container').highcharts({
- chart: {
- type: 'column'
- },
- title: {
- text: 'Data Pasien Menurut Jenis Kelamin'
- },
- subtitle: {
- 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>'
- },
- xAxis: {
- type: 'category',
- labels: {
- rotation: -45,
- style: {
- fontSize: '13px',
- fontFamily: 'Verdana, sans-serif'
- }
- }
- },
- yAxis: {
- min: 0,
- title: {
- text: 'Jumlah Pasien'
- }
- },
- legend: {
- enabled: true
- },
- tooltip: {
- pointFormat: 'jumlah : <b>{point.y:.1f} Ribu </b>'
- },
- series: [{
- name: 'Kelamin',
- data: [
- <?php
- foreach($data as $key=>$val){
- printf("\n['%s',%f],", $key,$val);
- }
- ?>
- ],
- dataLabels: {
- enabled: true,
- rotation: -90,
- color: '#FFFFFF',
- align: 'right',
- format: '{point.y:.1f}', // one decimal
- y: 10, // 10 pixels down from the top
- style: {
- fontSize: '13px',
- fontFamily: 'Verdana, sans-serif'
- }
- }
- }]
- });
- ///======================
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment