This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
lnhighchart/classes/HighChart/Combo.php

130 lines
2.5 KiB
PHP
Raw Normal View History

2013-11-14 12:17:30 +00:00
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides Combo HighCharts
*
* @package HighChart
* @category Helper
* @author Deon George
* @copyright (c) 2012-2013 Deon George
* @license http://dev.leenooks.net/license.html
*/
class HighChart_Combo extends HighChart {
private $_autopie_columns = array();
protected $_valid_axis = array(
'column',
'spline',
'pie',
);
/**
* Generate a PIE chart with the totals for each series
*/
public function autopie($column) {
array_push($this->_autopie_columns,$column);
}
/**
* Get our series data, and return it as a JSON array
*/
public function json() {
$result = array();
// For our auto pie columns (on the left side), we need to build that.
if (count($this->_autopie_columns) > 1) {
$htpo = $this->series('pie','float');
foreach ($this->_series['yl'] as $data)
$htpo->series_add($data->name(),$data->total(),array('color'=>$this->series_colour($data->index())));
$htpo->size(50);
$htpo->center(50,5);
}
foreach ($this->_series as $axis => $values) {
Sort::MASort($this->_series[$axis],array('order()'),0,FALSE);
2013-11-14 12:17:30 +00:00
foreach ($this->_series[$axis] as $data) {
array_push($result,$data->as_array(array('color'=>$this->series_colour($data->index()))));
}
}
return json_encode($result);
}
public function render() {
Script::add(array(
'type'=>'file',
'data'=>'media/js/highcharts.js',
));
Script::add(array(
'type'=>'file',
'data'=>'media/js/modules/exporting.js',
));
Script::add(array(
'type'=>'stdin',
'data'=>"
$(document).ready(function() {
$('#".$this->_divname."').highcharts({
chart: {
height: ".$this->_height.",
width: ".$this->_width.",
},
title: {
text: '".$this->_title."',
y: 3
},
xAxis: {
title: {
text: 'Month'
},
labels: {
style: {
'font-size': '50%',
'font-weight': 'bold',
},
},
ticklength: 2,
categories: []
},
yAxis: {
title: {
2013-11-22 04:19:01 +00:00
text: '".$this->_ymetric."'
2013-11-14 12:17:30 +00:00
},
labels: {
formatter: function() {
return this.value;
}
},
},
tooltip: {
formatter: function() {
var s;
2013-11-22 04:19:01 +00:00
s = '' + (this.point.name ? this.point.name+': ' : '') + this.y +' ".$this->_ymetric."';
2013-11-14 12:17:30 +00:00
return s;
}
},
credits: {
enabled: false
},
plotOptions: {
series: {
stacking: 'normal'
},
column: {
pointPadding: 0,
groupPadding: 0.1
}
},
series: ".$this->json().",
});
});",
));
return sprintf('<div id="%s"></div>',$this->_divname);
}
}
?>