无法从HighCharts生成图表

时间:2015-11-26 06:25:48

标签: javascript php mysql json highcharts

我使用下面的代码为我的系统生成使用HighCharts的条形图。问题是图表没有生成.sql查询正在工作,我觉得问题是json_encode我做错了什么?

<div id="container" style="width:100%; height:400px;"></div>

<?php

 $data = array();
 $label=array();
$result=mysqli_query($conn,"SELECT * FROM job_output group by Line_Number");
     foreach ($result as $value) :
     $data[] = $value['O_Total'];
     $label[] = $value['Line_Number'];
     array_push($data,$label);
    endforeach;


   ?>
   <script>
  $(document).ready(function() {
  var chart = new Highcharts.Chart({
            chart: {
             renderTo: 'container',
             type  :'bar'
                    },
             title: {
                    text: 'Production'
                     },
             xAxis: {
             categories: [<?php echo json_encode('$label')?>]
                    },
             series: [{
            data: [<?php echo json_encode('$data')?>],
            pointStart: 0,

                   }]
               });

        });

         </script>  

0 个答案:

没有答案