请帮我绘制谷歌图表Codeigniter

jgovgodb  于 2022-12-07  发布在  其他
关注(0)|答案(1)|浏览(135)

我有一个问题。谷歌图表不画。我检查了php代码和脚本没有php代码,它的确定。但当我把他们放在一起,谷歌图表不画。我的英语不好。对不起。php code result
[脚本结果

<script type="text/javascript">
      google.charts.load('current', {'packages':['bar']});
      google.charts.setOnLoadCallback(drawChart);

      function drawChart() {
        var data = google.visualization.arrayToDataTable([
            ['Month', 'Bán ra', 'Đơn hàng'],
            <?php 
            $d=getdate();
            $year=$d['year'];
            for ($i=1; $i <= 12 ; $i++) 
            {   
                $list_orrders = $this->transaction_model->order_follow_month($year, $i);
                $sum = 0;
                foreach ($list_orrders as $row_orrder) 
                {
                    $sum = $this->order_model->get_sum('qty',array('cart_id'=>$row_orrder->id));

                }
                if($i >= 1 && $i <=9)
                {
                    echo "['0".$i.'/'.$year."',".$sum.",".count($list_orrders)."],";
                }
                else
                {
                    echo "['".$i.'/'.$year."',".$sum.",".count($list_orrders)."],";
                }
            }
             ?>
            ]);

        var options = {
          chart: {
            title: 'Company Performance',
            subtitle: 'Sales, Expenses',
          }
        };

        var chart = new google.charts.Bar(document.getElementById('columnchart_material'));

        chart.draw(data, google.charts.Bar.convertOptions(options));
      }
    </script>

[英]

vqlkdk9b

vqlkdk9b1#

看起来你的<?php没有被解释,你的$this->transaction_model->order_follow_month($year, $i);$this->order_model->get_sum('qty',array('cart_id'=>$row_orrder->id));在这里不知从哪里来。

相关问题