Highchart按月从相应的列数据开始

时间:2016-05-30 11:18:55

标签: php codeigniter highcharts

我有问题要在高保真类别上按月对这些数据进行分组 enter image description here
这是系列数据的控制器代码:

public function ajax_chart_data()
{
    $data = $this->lap_model->get_data();

    if (empty($data)){
        return json_encode('Tidak ada data');
    }else {
        foreach ($data as $row) {
            $series_data[] = array(
                'name' => $row->Nama_Negara,
                'data' => [$row->Amount],
                'month' => $row->Month
                );
        }
        return json_encode($series_data, JSON_NUMERIC_CHECK);
    }

}

这是我的观看代码:

<script type="text/javascript">
var base_url = "<?php base_url(); ?>";
var rpt1;
jQuery(document).ready(function()
{
    $('#rpt1').highcharts({
        chart: {
            type: 'column',
            borderWidth: 1
        },
        title: {
            text: 'Registration Data'
        },
        yAxis: {
            title: {
                text: 'Reg. Amount'
            }
        },
        series: <?php echo $series_data ?>
    });
});

<div class="container">
  <div class="row">
    <div class="col-md-6">
        <div id="rpt1" style="width:100%; height:400px;"></div>
    </div>
  </div>
</div>

这是我的高潮图的当前结果:
enter image description here
我期望按照上面显示的数据按月分组数据。

如果需要,这是ajax函数返回的数据:

[{"name":"Brunei Darussalam","data":[5],"month":5},{"name":"Korea","data":[2],"month":4},{"name":"Korea","data":[3],"month":5},{"name":"Malaysia","data":[1],"month":4},{"name":"Malaysia","data":[6],"month":5},{"name":"Saudi Arabia","data":[2],"month":3},{"name":"Saudi Arabia","data":[1],"month":4},{"name":"Saudi Arabia","data":[8],"month":5},{"name":"Singapore","data":[1],"month":3},{"name":"Singapore","data":[6],"month":5},{"name":"Taiwan","data":[2],"month":3},{"name":"Taiwan","data":[1],"month":4},{"name":"Taiwan","data":[3],"month":5}]

我希望你们明白我的意思和我所期待的,抱歉,并提前多多感谢。

#UPDATE: 这是我在jsfiddle上运行的代码:https://jsfiddle.net/HealMee/j32440f8/

1 个答案:

答案 0 :(得分:1)

你的母马是什么 一个月马叻 - 沙特阿拉伯2 - 台湾2 - 新加坡1 四月份 - 马来西亚1 - 沙特阿拉伯1 - 韩国2 - 台湾1