I'm making a pie chart of expenses using JavaScript and CodeIgniter.
Controller
chart_c
function getchart1() {
    $result['query']=$this->model_m->getchart2();
    $this->load->view('chartview',$result);
}
model_m
function getchart2() {
    $query = $this->db->get('qpaper');
    return $query->result();
}
View
foreach($query as $row) {
    $ex=$row->expenses;
    $cat=$row->category;
}
How can I access $row->expenses and $row->category from the script above in the following JavaScript? 
var data = google.visualization.arrayToDataTable([
    ['Task', 'Hours per Day'],////how i will insert the data from db 
    ['Work',     11],///my doubt here $e how i will put here
    ['Eat',      2],
    ['Commute',  2],
    ['Watch TV', 2],
    ['Sleep',    7]
]);
The full code:
<html>
    <head>
        <script type="text/javascript" src="https://www.google.com/jsapi"></script>
        <script type="text/javascript">
            google.load("visualization", "1", {packages:["corechart"]});
            google.setOnLoadCallback(drawChart);
            function drawChart() {
                var data = google.visualization.arrayToDataTable([
                    ['Task', 'Hours per Day'],////how i will insert the data from db 
                    ['Work',     11],///my doubt here $e how i will put here
                    ['Eat',      2],
                    ['Commute',  2],
                    ['Watch TV', 2],
                    ['Sleep',    7]
                ]);
                var options = {
                  title: 'My Daily Activities'
                };
                var chart = new google.visualization.PieChart(document.getElementById('piechart'));
                chart.draw(data, options);
            }
        </script>
    </head>
    <body>
        <div id="piechart" style="width: 900px; height: 500px;"></div>
    </body>
</html>
 
    