I wanna see the value of series Highchart, but when I debug it just not show the values. This is my code
and this is my view
<script type="text/javascript" src="<?php echo base_url(); ?>public/jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="<?php echo base_url(); ?>public/highcharts/js/highcharts.js"></script>
<script type="text/javascript" src="<?php echo base_url(); ?>public/highcharts/js/highcharts-3d.js"></script>
<script type="text/javascript" src="<?php echo base_url(); ?>public/highcharts/js/modules/exporting.js"></script>
<script type="text/javascript" src="<?php echo base_url(); ?>public/highcharts/js/themes/grid-light.js"></script>
<style type="text/css">
</style>
<script type="text/javascript">
var chart1;
jQuery(document).ready(function(){
chart1 = new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'column',
borderWidth: 2,
animation: {
duration: 1000
},
spacingRight: 25,
backgroundColor: {
linearGradient: [0, 0, 500, 500],
stops: [
[0, 'rgb(255, 255, 255)'],
[1, 'rgb(229, 238, 238)']
]
},
},
tooltip: {
backgroundColor: '#FCFFC5',
shadow: true,
},
title: {
text: 'Store Chart'
},
credits: {
enabled: false
},
xAxis: {
categories: [<?php echo "'".implode("','",$branch_name)."'";?>]
},
yAxis: {
title: {
text: 'Tingkat Penjualan'
}
},
exporting: {
buttons: {
contextButton: {
text: 'Export'
}
}
},
series: [<?php echo "'".implode("','",$branch_sell)."'";?>],
plotOptions: {
series: {
color: '#66B2FF'
}
}
});
});
</script>
and this is controller
public function index()
{
$data = array();
$this->menu_handler->set_header($data,1,0);
$this->load->model('m_admin');
$get_branch = $this->m_admin->get_chart_store();
$get_selling_store = $this->m_admin->get_sell_store();
$data['branch_name'] = array();
$data['branch_sell'] = array();
for($i=0,$n=count($get_branch); $i<$n; $i++)
{
$data['branch_name'][] = $get_branch[$i]->NAMA_CABANG;
}
for($i=0,$n=count($get_selling_store); $i<$n; $i++)
{
$data['branch_sell'][] = $get_selling_store[$i]->rslt;
}
$series_data[] = array('name' => 'Branch Store', 'data' => array($get_selling_store));
$data['series_data'] = json_encode($series_data);
$this->load->view('welcome_message', $data);
global $file_counter,$error_file,$size_counter;
}
and this is my model
<?php if (!defined('BASEPATH'))
exit('No direct script access allowed');
function get_chart_store($id_store=''){
global $sec_database;
if(empty($id_store))
{
$get_detail = $sec_database->select('*')->get('MST_CABANG')->result();
}
else
{
$get_detail = $sec_database->select('*')->where('CABANG_ID',$id_store)->get('MST_CABANG')->result();
}
if(count($get_detail) > 0)
{
return $get_detail;
}
else
{
return 1;
}
}
function get_sell_store($id_sell='')
{
global $sec_database;
$q_detailstore = "
SELECT
sd.CABANG_ID,
sd.`NAMA_CABANG`,
SUM(SALES_TOTAL) as rslt
FROM
MST_SALES as md
RIGHT JOIN MST_CABANG as sd
ON md.`CABANG_ID` = sd.CABANG_ID
GROUP BY
sd.CABANG_ID
";
$get_detail_selling = $sec_database->query($q_detailstore,array($id_sell))->result();
if(count($get_detail_selling) > 0)
{
return $get_detail_selling;
}
else
{
return 1;
}
}
the chart just show the series, but how I can get value of series to the chart? sorry I'm newbie.. thx before
implode()
does't work with multidimensional array. so It's not printing value
try
$data['branch_name'] = $get_branch[$i]->NAMA_CABANG;
instead of
$data['branch_name'][] = $get_branch[$i]->NAMA_CABANG;
in your controller. same as for your branch_sell variable
UPDATE
for($i=0,$n=count($get_branch); $i<$n; $i++)
{
$data['branch_name'] = $get_branch[$i]->NAMA_CABANG;
}
array_walk($data['branch_name'],function (&$val){ $val="'".$val."'";});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.