
    LoadDadta(null);
    function LoadDadta(id){
        $(document).ready(function(){
            /* save data */
            $.ajax({
                type: 'POST',
                dataType: 'json',
                url: baseURL + '/api/loadchart',
                data: {
                    id   : id,
                },
                success: function(result){
                    
                    if(result.code == 0){
                        
                        let data = result.data;
                        var nama_kota = [];
                        let jumlah = [];
                        //let counter = 0;
                        for(x in data){
                            //console.log(data[x].nama_kota);
                            nama_kota[x] = data[x].nama_kota;
                            jumlah[x] = data[x].jumlah;
                        }
                        
                        console.log(nama_kota);
                        console.log(jumlah);

                        var ctx = document.getElementById("myPieChart2");
                        var myPieChart = new Chart(ctx, {
                        type: 'pie',
                        data: {
                            labels: nama_kota,
                            datasets: [{
                            data: jumlah,
                            backgroundColor: ['#4e73df', '#1cc88a', '#36b9cc', '#f6c23e', "#c5c5c5"],
                            hoverBackgroundColor: ['#2e59d9', '#17a673', '#2c9faf', '#ffd700', '#c5c5c5'],
                            hoverBorderColor: "rgba(234, 236, 244, 1)",
                            }],
                        },
                        options: {
                            maintainAspectRatio: false,
                            tooltips: {
                            backgroundColor: "rgb(255,255,255)",
                            bodyFontColor: "#858796",
                            borderColor: '#dddfeb',
                            borderWidth: 1,
                            xPadding: 15,
                            yPadding: 15,
                            displayColors: false,
                            caretPadding: 10,
                            },
                            legend: {
                            display: false
                            },
                            cutoutPercentage: 0,
                        },
                        });
                    }else{
                        alert(result.info);
                    }
                },
                error: function(xhr) {
                    alert(xhr.status+'-'+xhr.statusText);            
                }
            });
        });
    }
    
    //console.log(nama_kota);
