Membuat grafik dengan javascript tapi tidak muncul

Tolong ini saya bingung bikin grafik garis tapi ga mau muncul. Ini mau nampilin jml data perbulan. Aku cek query kaya udah bener, tapi tetep ga muncul apa2. makasih yg udah respon Ini query nya

include('./controller/koneksi.php');
                date_default_timezone_set('Asia/Jakarta');                        $tahun = date("Y");
                 $querylog1 = "SELECT COUNT(*) as jumlah FROM `radacct` WHERE acctstoptime > '0000-00-00 00:00:01' AND month(acctstoptime) = 1 and year(acctstoptime) = $tahun";
                 $sqllog1 = mysqli_query($koneksi, $querylog1);
                 $datalog1 = mysqli_fetch_row($sqllog1);


                        $querylog2 = "SELECT COUNT(*) as jumlah FROM `radacct` WHERE acctstoptime > '0000-00-00 00:00:01' AND month(acctstoptime) = 2 and year(acctstoptime) = $tahun";
                        $sqllog2 = mysqli_query($koneksi, $querylog2);
                        $datalog2 = mysqli_fetch_row($sqllog2);

//ini javascriptnya

var lineChartData = {
    labels: ['Januari', 'Februari', 'Maret', 'April', 'Mei', 'Juni', 'Juli', 'Agustus', 'September', 'Oktober',
        'November', 'Desember'
    ],
    datasets: [{
        label: 'Download(Gb)',
        borderColor: window.chartColors.red,
        backgroundColor: window.chartColors.red,
        fill: false,
        data: [<?php echo $datalog1; ?> , <?php echo $datalog2; ?>, <?php echo $datalog3; ?> , <?php echo $datalog4; ?> , <?php echo $datalog5; ?> , <?php echo $datalog6; ?> , <?php echo $datalog7; ?> , <?php echo $datalog8; ?> , <?php echo $datalog9; ?> , <?php echo $datalog10; ?> , <?php echo $datalog11; ?> , <?php echo $datalog12; ?>
        ],
        yAxisID: 'y-axis-1',
    }]
};

window.onload = function() {
    var ctx = document.getElementById('canvas2').getContext('2d');
    window.myLine = Chart.Line(ctx, {
        data: lineChartData,
        options: {
            responsive: true,
            hoverMode: 'index',
            stacked: true,
            scales: {
                yAxes: [{
                    type: 'linear', // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance
                    display: true,
                    position: 'left',
                    id: 'y-axis-1',
                }
                }],
        }
    });
};

avatar ratna712
@ratna712

4 Kontribusi 0 Poin

Dipost 4 tahun yang lalu

Tanggapan

coba cek di console browsernya, muncul error apa ngga ?

ini kemaren sudah bisa muncul grafik barunya, ganti grafik yang lama ga muncul. DI console errornya di sparkline.js nya error

coba lampirkan juga errornya seperti apa

Uncaught TypeError: this.element is undefined Sparkline http://localhost/PKL/radius/assets/plugins/sparklines/sparkline.js:28 <anonymous> http://localhost/PKL/radius/assets/dist/js/pages/dashboard.js:92 jQuery 2 e t sparkline.js:28:7 Sparkline http://localhost/PKL/radius/assets/plugins/sparklines/sparkline.js:28 <anonymous> http://localhost/PKL/radius/assets/dist/js/pages/dashboard.js:92 jQuery 2 e t

Belum ada Jawaban. Jadi yang pertama Jawaban

Login untuk ikut Jawaban