I have a problem to group this data by month on the highchart categories.
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:
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/