Skip to content Skip to sidebar Skip to footer

Morris Js And Codeigniter Pass Data From A Controller

I have the following controller which picks data from my DBase : function chart_js() { $rows = ''; $query = 'SELECT clnt_id,date_added FROM job_card ORDER BY date_added DES

Solution 1:

You need to ajax the data use $.getJSON

Try:

$.getJSON("<?php echo site_url('operations/char_js'); ?>", function (json) { 
            var acctregs = new Morris.Line({
                        // ID of the element in which to draw the chart.
                        element: 'acctregs',
                        // Chart data records -- each entry in this array corresponds to a point on
                        // the chart.
                        data: json,
                        // The name of the data record attribute that contains x-values.
                        xkey: 'date_added',
                        // A list of names of data record attributes that contain y-values.
                        ykeys: ['clnt_id'],
                        // Labels for the ykeys -- will be displayed when you hover over the
                        // chart.
                        labels: ['Value'],
                        dateFormat: function (x) {
                            return new Date(x).toString().split("00:00:00")[0];
                        }
                    });
        });

Post a Comment for "Morris Js And Codeigniter Pass Data From A Controller"