I'm using codeigniter with highcharts, but when I fetch the data from database, it only appears like this:
What do you think is the problem?
controller
public function tabular()
{
$data['pizzas'] = $this->user_model->tabular();
//var_dump($this->user_model->tabular());
$this->load->view('template/header');
$this->load->view('template/menubar');
$this->load->view('template/highcharts',$data);
$this->load->view('template/footer');
}
model
public function tabular() {
$this->db->select('products.name AS name, SUM(order_details.price) AS total');
$this->db->from('order_details');
$this->db->join('products', 'products.prod_id = order_details.prod_id', 'LEFT');
$this->db->group_by("products.prod_id");
$query = $this->db->get();
foreach ($query->result() as $row){
$results[] = array(
'name' => $row->name,
'total' => (float) $row->total
);
}
return $results;
}
view
Highcharts.chart('chart-C', {
chart: {
type: 'column'
},
title: {
text: 'Browser market shares. January, 2015 to May, 2015'
},
subtitle: {
text: 'Click the columns to view versions. Source: <a href="http://netmarketshare.com">netmarketshare.com</a>.'
},
xAxis: {
type: 'category'
},
yAxis: {
title: {
text: 'Total percent market share'
}
},
legend: {
enabled: false
},
plotOptions: {
series: {
borderWidth: 0,
dataLabels: {
enabled: true,
format: 'P{point.total:.2f}'
}
}
},
tooltip: {
headerFormat: '<span style="font-size:11px">{series.name}</span><br>',
pointFormat: '<span style="color:{point.color}">{point.name}</span>: <b>P{point.total:.2f}</b> of total<br/>'
},
series: [{
name: 'Sales',
colorByPoint: true,
data: <?php echo json_encode($pizzas); ?>
}],
});
json_encode var_dump
string '[{"name":"pizza burger","total":870},{"name":"buffalo chicken","total":1085},{"name":"bacon mushroom","total":165},{"name":"sausage mania","total":450},{"name":"beef shawarma","total":1575},{"name":"yummy hotdog","total":230},{"name":"oreo pina","total":240},{"name":"tuna garlic","total":130},{"name":"all hungarian","total":135},{"name":"beef pepperoni","total":135},{"name":"hawaiian","total":480}]' (length=401)