92 lines
1.6 KiB
PHP
92 lines
1.6 KiB
PHP
|
<?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_Bubble extends HighChart {
|
||
|
protected $_data_type = array(
|
||
|
'bubble',
|
||
|
);
|
||
|
|
||
|
/**
|
||
|
* Get our series data, and return it as a JSON array
|
||
|
*/
|
||
|
public function json() {
|
||
|
$output = '';
|
||
|
|
||
|
$result = array();
|
||
|
Sort::MASort($this->_series,'order()',0);
|
||
|
|
||
|
foreach ($this->_series as $axis => $datapoints) {
|
||
|
if ($output)
|
||
|
$output .= ',';
|
||
|
|
||
|
$result['data'] = array();
|
||
|
|
||
|
foreach ($datapoints as $o)
|
||
|
array_push($result['data'],$o->as_array());
|
||
|
|
||
|
$result['name'] = $axis;
|
||
|
|
||
|
$output .= json_encode($result);
|
||
|
}
|
||
|
|
||
|
return '['.$output.']';
|
||
|
}
|
||
|
|
||
|
public function render() {
|
||
|
parent::render_init();
|
||
|
|
||
|
Script::add(array(
|
||
|
'type'=>'file',
|
||
|
'data'=>'media/js/highcharts-more.js',
|
||
|
));
|
||
|
|
||
|
Script::add(array(
|
||
|
'type'=>'stdin',
|
||
|
'data'=>"
|
||
|
$(document).ready(function() {
|
||
|
$('#".$this->_divname."').highcharts({
|
||
|
chart: {
|
||
|
type: 'bubble',
|
||
|
height: ".$this->_height.",
|
||
|
width: ".$this->_width.",
|
||
|
},
|
||
|
title: {
|
||
|
text: '".$this->_title."',
|
||
|
},
|
||
|
subtitle: {
|
||
|
text: '".$this->_subtitle."',
|
||
|
},
|
||
|
xAxis: {
|
||
|
title: {
|
||
|
text: '".$this->_xmetric."'
|
||
|
},
|
||
|
},
|
||
|
yAxis: {
|
||
|
title: {
|
||
|
text: '".$this->_ymetric."'
|
||
|
},
|
||
|
},".($this->_tooltip ? "
|
||
|
tooltip: {
|
||
|
pointFormat: '".$this->_tooltip."',
|
||
|
}," : '')."
|
||
|
credits: {
|
||
|
enabled: false
|
||
|
},
|
||
|
series: ".$this->json().",
|
||
|
});
|
||
|
});",
|
||
|
));
|
||
|
|
||
|
return parent::render_post();
|
||
|
}
|
||
|
}
|
||
|
?>
|