Cara Mengambil Data Array di DB untuk menampilkan pada Highchart

<?php
$tglAwal = $_GET['txt_tglAwal'];
$tglAkhir = $_GET['txt_tglAkhir'];

if(@$_GET['Select_Department']){
$sqlManHour="Select SUM(duration)duration,username from ManHour Inner Join Department on ManHour.departmentID=Department.departmentID
			 WHERE ManHour.departmentID ='$position' AND
			 dateManHour BETWEEN '$tglAwal' AND '$tglAkhir' Group by username";
}else if(empty($_GET['Select_Department'])){
	$sqlManHour="Select SUM(duration)duration,username from ManHour Inner Join Department on ManHour.departmentID=Department.departmentID
			 WHERE dateManHour BETWEEN '$tglAwal' AND '$tglAkhir' Group by username";
}
	$nampil = sqlsrv_query($con,$sqlManHour);

	$durationManHour = array();
	$username = array();
	while($data = sqlsrv_fetch_array($nampil,SQLSRV_FETCH_ASSOC)){
		$durationManHour[] = $data['duration'];
		$username[] = $data['username'];
	}
	print_r($username);

?>


<script type="text/javascript">
Highcharts.chart('data_manhour', {
    chart: {
        type: 'column'
    },
    title: {
        text: 'Data Man Hour'
    },
    subtitle: {
        text: 'Source: Man Hour'
    },
    xAxis: {
        categories: <?= json_encode($username)?>,
        tickmarkPlacement: 'on',
        title: {
            enabled: false
        }
    },
    yAxis: {
        title: {
            text: 'Total'
        },
        labels: {
            formatter: function () {
                return this.value;
            }
        }
    },
    tooltip: {
        formatter: function () {
 return '<b>' + this.x + '</b><br/>' +
 this.series.name + ': ' + this.y + '<br/>' +
 'Total: ' + this.point.stackTotal;
 }
    },
    plotOptions: {
        area: {
            stacking: 'normal',
            lineColor: '#666666',
            lineWidth: 1,
            marker: {
                lineWidth: 1,
                lineColor: '#666666'
            }
        }
    },
 credits: {
    enabled: false
 },    series: [{        name: 'duration',
        data: <?= json_encode($durationManHour)?>
    }]
});
</script>

Haii Guys,

Saat ini di ada 3 data pegawai. saya sudah bisa mengambil total durasi kerja dari

3 pegawai tersebut. tetapi saya belum nemu cara untuk menampilkan detail dari total durasi kerja dari 3 pegawai tersebut. apkah menggunakan for diloop 1" untuk mengambil data masing-masing? mohon dibantu ya guys. terima kasih.

avatar MichaelGlenn
@MichaelGlenn

1 Kontribusi 0 Poin

Dipost 4 tahun yang lalu

Belum ada Jawaban. Jadi yang pertama Jawaban

Login untuk ikut Jawaban