Skip to content
Snippets Groups Projects
Commit 0fa076ea authored by Kevin Hill's avatar Kevin Hill
Browse files

Merge branch '3.0-dev' into 3.0

parents 7a304025 04038055
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -248,7 +248,8 @@ var lava = lava || {};
this.run = function (window) {
var s = document.createElement('script');
s.type = 'text/javascript';
s.src = 'https://www.google.com/jsapi';
//s.src = 'https://www.google.com/jsapi';
s.src = 'https://www.gstatic.com/charts/loader.js';
s.onload = s.onreadystatechange = function (event) {
event = event || window.event;
 
Loading
Loading
Loading
Loading
@@ -212,7 +212,9 @@ class Chart extends JsonConfig
*/
public function customize($optionArray)
{
return $this->options->setOptions($optionArray, false);
$this->options->setOptions($optionArray, false);
return $this;
}
 
/**
Loading
Loading
Loading
Loading
@@ -3,6 +3,8 @@
namespace Khill\Lavacharts\DataTables\Columns;
 
 
use \Khill\Lavacharts\JsonConfig;
use Khill\Lavacharts\Options;
use \Khill\Lavacharts\Utils;
use \Khill\Lavacharts\DataTables\Formats\Format;
 
Loading
Loading
@@ -21,7 +23,7 @@ use \Khill\Lavacharts\DataTables\Formats\Format;
* @link http://lavacharts.com Official Docs Site
* @license http://opensource.org/licenses/MIT MIT
*/
class Column implements \JsonSerializable
class Column extends JsonConfig
{
/**
* Column type.
Loading
Loading
@@ -51,21 +53,33 @@ class Column implements \JsonSerializable
*/
protected $role = '';
 
/**
* Allowed options to set for the column.
*
* @var \Khill\Lavacharts\Options
*/
protected $options = null;
/**
* Creates a new Column with the defined label.
*
* @access public
* @param string $type Type of Column
* @param string $type Type of Column
* @param string $label Column label (optional).
* @param \Khill\Lavacharts\DataTables\Formats\Format $format
* @param string $role Column role (optional).
* @param string $role Column role (optional).
* @param array $options
*/
public function __construct($type, $label = '', Format $format = null, $role = '')
public function __construct($type, $label = '', Format $format = null, $role = '', array $options = [])
{
$this->type = $type;
$this->label = $label;
$this->format = $format;
$this->role = $role;
$this->type = $type;
$this->label = $label;
$this->format = $format;
$this->role = $role;
if (count($options) > 0) {
$this->options = $options;
}
}
 
/**
Loading
Loading
@@ -141,6 +155,10 @@ class Column implements \JsonSerializable
 
if (Utils::nonEmptyString($this->role) === true) {
$values['p'] = ['role' => $this->role];
if (count($this->options) > 0) {
$values['p'] = array_merge($values['p'], $this->options);
}
}
 
return $values;
Loading
Loading
Loading
Loading
@@ -75,15 +75,16 @@ class ColumnFactory
*
* @access public
* @since 3.0.0
* @param string $type Type of column to create.
* @param string $label A label for the column.
* @param \Khill\Lavacharts\DataTables\Formats\Format $format Column formatter for the data.
* @param string $role A role for the column to play.
* @param string $type Type of column to create.
* @param string $label A label for the column.
* @param \Khill\Lavacharts\DataTables\Formats\Format $format Column formatter for the data.
* @param string $role A role for the column to play.
* @param array $options Options for the column.
* @return \Khill\Lavacharts\DataTables\Columns\Column
* @throws \Khill\Lavacharts\Exceptions\InvalidColumnRole
* @throws \Khill\Lavacharts\Exceptions\InvalidColumnType
*/
public static function create($type, $label = '', Format $format = null, $role = '')
public static function create($type, $label = '', Format $format = null, $role = '', array $options = [])
{
if (Utils::nonEmptyStringInArray($type, self::$TYPES) === false) {
throw new InvalidColumnType($type, self::$TYPES);
Loading
Loading
@@ -108,6 +109,7 @@ class ColumnFactory
}
 
$columnArgs[] = $role;
$columnArgs[] = $options;
 
$column = new \ReflectionClass('\Khill\Lavacharts\DataTables\Columns\Column');
 
Loading
Loading
Loading
Loading
@@ -433,30 +433,30 @@ class DataTable implements \JsonSerializable
*
* @access public
* @since 3.0.0
* @param string $type Type of data the column will define.
* @param string $role Type of role that the data will represent.
* @param string $type Type of data the column will define.
* @param string $role Type of role that the data will represent.
* @param array $options Extra options for the column.
* @return \Khill\Lavacharts\DataTables\DataTable
* @throws \Khill\Lavacharts\Exceptions\InvalidColumnType
* @throws \Khill\Lavacharts\Exceptions\InvalidColumnRole
*/
public function addRoleColumn($type, $role)
public function addRoleColumn($type, $role, array $options = [])
{
return $this->createColumnWithParams($type, '', null, $role);
return $this->createColumnWithParams($type, '', null, $role, $options);
}
 
/**
* Supplemental function to create columns from strings.
*
* @access protected
* @param string $type Type of column to create
* @param string $label Label for the column. (Optional)
* @param \Khill\Lavacharts\DataTables\Formats\Format $format A column format object. (Optional)
* @param string $role A role for the column. (Optional)
* @param string $type Type of column to create
* @param string $label Label for the column. (Optional)
* @param Format $format A column format object. (Optional)
* @param string $role A role for the column. (Optional)
* @param array $options Extra options for the column. (Optional)
* @return \Khill\Lavacharts\DataTables\DataTable
*/
protected function createColumnWithParams($type, $label = '', $format = null, $role = '')
protected function createColumnWithParams($type, $label = '', $format = null, $role = '', array $options = [])
{
$this->cols[] = ColumnFactory::create($type, $label, $format, $role);
$this->cols[] = ColumnFactory::create($type, $label, $format, $role, $options);
 
return $this;
}
Loading
Loading
@@ -625,7 +625,7 @@ class DataTable implements \JsonSerializable
public function getRowCount()
{
return count($this->rows);
}
}
 
/**
* Returns a column based on it's index.
Loading
Loading
Loading
Loading
@@ -191,7 +191,7 @@ class ChartFactory extends JavascriptFactory
 
lava.registerChart("<chartType>", "<chartLabel>");
 
google.load('visualization', '<chartVer>', {
google.charts.load('current', {
packages: ['<chartPackage>'],
callback: function() {
lava.charts.<chartType>["<chartLabel>"].render();
Loading
Loading
Loading
Loading
@@ -291,10 +291,10 @@ class JsonConfig implements \JsonSerializable
/**
* Custom serialization of the JsonConfig object.
*
* @return array
* @return string
*/
public function jsonSerialize()
{
return $this->options;
return json_encode($this->options);
}
}
Loading
Loading
@@ -37,7 +37,7 @@ class Lavacharts
/**
* Lavacharts version
*/
const VERSION = '3.0.4';
const VERSION = '3.0.6';
 
/**
* Holds all of the defined Charts and DataTables.
Loading
Loading
Loading
Loading
@@ -21,7 +21,7 @@ use \Khill\Lavacharts\Exceptions\InvalidOption;
* @link http://lavacharts.com Official Docs Site
* @license http://opensource.org/licenses/MIT MIT
*/
class Options implements \JsonSerializable
class Options implements \JsonSerializable, \Countable
{
/**
* Default options that can be set.
Loading
Loading
@@ -55,6 +55,18 @@ class Options implements \JsonSerializable
$this->options = $options;
}
 
/**
* Returns the number of set options.
*
* @since 3.0.6
* @access public
* @return int
*/
public function count()
{
return count($this->options);
}
/**
* Returns the array of options that can be set.
*
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment