Skip to content
This repository has been archived by the owner on Apr 27, 2022. It is now read-only.

Commit

Permalink
sederhanakan kode di statistik dan hapus source js yang tidak diperlukan
Browse files Browse the repository at this point in the history
  • Loading branch information
dikisiswanto committed Jun 14, 2020
1 parent 5fe7548 commit 483d2f6
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 109 deletions.
6 changes: 2 additions & 4 deletions commons/source_js.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<?php if(!defined('BASEPATH')) exit('No direct script access allowed'); ?>

<script src="<?= base_url("$this->theme_folder/$this->theme/assets/js/vendor.min.js") ?>"></script>
<script src="<?= base_url()?>assets/js/highcharts/highcharts.js"></script>
<script src="<?= base_url()?>assets/js/highcharts/highcharts-3d.js"></script>
<script src="<?= base_url()?>assets/js/highcharts/exporting.js"></script>
<script src="<?= base_url()?>assets/js/highcharts/highcharts-more.js"></script>
<script src="<?= base_url("assets/js/highcharts/highcharts.js")?>"></script>
<script src="<?= base_url("assets/js/highcharts/highcharts-3d.js")?>"></script>
<script src="<?= base_url("assets/front/js/jquery.cycle2.min.js")?>"></script>
<script src="<?= base_url("assets/front/js/jquery.cycle2.carousel.js")?>"></script>
<script src="<?= base_url("assets/js/leaflet.js")?>"></script>
Expand Down
174 changes: 69 additions & 105 deletions partials/statistik/statistik.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,16 @@
<script type="text/javascript">
let chart;
const raw = Object.values(<?= json_encode($stat) ?>);
const typechart = '<?= $tipe == 1 ? 'column' : 'pie' ?>';
const legend = Boolean(!<?= ($tipe) ?>);
let categories = [];
let data = [];
let i = 1;
let status_tampilkan = true;
const enable3d = <?= $this->setting->statistik_chart_3d ?> ? true: false;
let chartType = 'pie';
const categories = [];
const data = [];
let showStatus = true;
for (const stat of raw) {
if (stat.nama !== 'TOTAL' && stat.nama !== 'JUMLAH' && stat.nama != 'PENERIMA') {
let filteredData = [stat.nama, parseInt(stat.jumlah)];
categories.push(i);
categories.push(stat.nama);
data.push(filteredData);
i++;
}
}

Expand All @@ -34,105 +32,70 @@ function showHideToggle() {
else $('#tampilkan').text('Sembunyikan Nol');
}

function switchType(){
var chartType = chart_penduduk.series[0].type;
chart_penduduk.series[0].update({
type: (chartType === 'pie') ? 'column' : 'pie'
function switchType(type, alpha){
chart.update({
chart: {
options3d: {
alpha: alpha
}
},
series: [{
type: type
}]
});
}

$(document).ready(function () {
showZeroValue(false);
if (<?=$this->setting->statistik_chart_3d?>) {
chart_penduduk = new Highcharts.Chart({
chart: {
renderTo: 'container',
options3d: {
enabled: true,
alpha: 45
}
},
title: 0,
yAxis: {
showEmpty: false,
title: {
text: 'Jumlah Populasi'
}
},
xAxis: {
categories: categories,
},
plotOptions: {
series: {
colorByPoint: true
},
column: {
pointPadding: -0.1,
borderWidth: 0,
showInLegend: false,
depth: 45
},
pie: {
allowPointSelect: true,
cursor: 'pointer',
showInLegend: true,
depth: 45,
innerSize: 70
}
},
legend: {
enabled: legend
},
series: [{
type: typechart,
name: 'Jumlah Populasi',
shadow: 1,
border: 1,
data: data
}]
});
} else {
chart_penduduk = new Highcharts.Chart({
chart: {
renderTo: 'container'
},
title: 0,
yAxis: {
showEmpty: false,
title: {
text: 'Jumlah Populasi'
}
},
xAxis: {
categories: categories,
},
plotOptions: {
series: {
colorByPoint: true
},
column: {
pointPadding: -0.1,
borderWidth: 0,
showInLegend: false,
},
pie: {
allowPointSelect: true,
cursor: 'pointer',
showInLegend: true,
}
},
legend: {
enabled: legend
},
series: [{
type: typechart,
name: 'Jumlah Populasi',
shadow: 1,
border: 1,
data: data
}]
});
}
$(document).ready(function () {
showZeroValue(false);
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
options3d: {
enabled: enable3d,
alpha: 45,
beta: 10
}
},
title: 0,
yAxis: {
showEmpty: false,
title: {
text: 'Jumlah Populasi'
}
},
xAxis: {
categories: categories,
},
plotOptions: {
series: {
colorByPoint: true
},
column: {
pointPadding: -0.1,
borderWidth: 0,
showInLegend: false,
depth: 50,
viewDistance: 25
},
pie: {
allowPointSelect: true,
cursor: 'pointer',
showInLegend: false,
depth: 30,
innerSize: 30,
}
},
legend: {
enabled: true
},
series: [{
type: chartType,
name: 'Jumlah Populasi',
shadow: 1,
border: 1,
data: data
}]
});

$('#showData').click(function () {
$('tr.lebih').show();
Expand All @@ -142,11 +105,12 @@ function switchType(){

$('.btn-switch').click(function () {
chartType = $(this).data('type');
let alpha = chartType == 'pie' ? 45 : 20;
$(this).addClass('btn-primary');
$(this).removeClass('btn-default')
$(this).siblings('.btn').removeClass('btn-primary');
$(this).siblings('.btn').addClass('btn-default');
switchType(chartType);
switchType(chartType, alpha);
})

});
Expand Down

0 comments on commit 483d2f6

Please sign in to comment.