dongqin6926 2016-05-30 11:18
浏览 71

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

I have a problem to group this data by month on the highchart categories.
enter image description here
Here's my controller code for the series data:

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);
    }

}

And here's my view code :

<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>

And here's the current result of my highchart:
enter image description here
I was expecting to group the data by monthly based as the data shown above.

Here's the data that returned by the ajax function if needed:

[{"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}]

I hope you guys understand what i mean and what im expecting, sorry for the trouble and many thanks in advance.

#Update: Here's my code running on jsfiddle: https://jsfiddle.net/HealMee/j32440f8/

  • 写回答

1条回答 默认 最新

  • doudou_3636 2016-05-30 15:10
    关注

    What your maen is Month Maret - Saudi Arab 2 - Taiwan 2 - Singapore 1 Month April - Malaysia 1 - Saudi arab 1 - Korea 2 - Taiwan 1

    评论

报告相同问题?

悬赏问题

  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端