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

JoinedDataTables work! #146 [ci skip]

parent 71418deb
No related branches found
No related tags found
No related merge requests found
Showing
with 314 additions and 156 deletions
This diff is collapsed.
Loading
Loading
@@ -75,16 +75,24 @@ module.exports = (function() {
* @public
* @external "google.visualization.DataTable"
* @see {@link https://developers.google.com/chart/interactive/docs/reference#DataTable|DataTable Class}
* @param {object} data Json representation of a DataTable
* @param {Array.<Array>} data.cols Array of column definitions
* @param {Array.<Array>} data.rows Array of row definitions
* @param {object} payload Json representation of a DataTable
*/
Chart.prototype.setData = function (data) {
if (data instanceof google.visualization.DataTable) {
this.data = data;
Chart.prototype.setData = function (payload) {
// If a DataTable#toJson() payload is received, with formatted columns,
// then data.data will be defined, and used as the DataTable
if (typeof payload.data === 'object') {
payload = payload.data;
}
 
this.data = new google.visualization.DataTable(data);
// Since Google compiles their classes, we can't use instanceof to check since
// it is no longer called a "DataTable" (it's "gvjs_P" but that could change...)
if (typeof payload.getTableProperties === 'function') {
this.data = payload;
// Otherwise assume it is a JSON representation of a DataTable and create one.
} else {
this.data = new google.visualization.DataTable(payload);
}
};
 
/**
Loading
Loading
Loading
Loading
@@ -2,6 +2,8 @@
 
namespace Khill\Lavacharts\Builders;
 
//@TODO refactor this class
use Khill\Lavacharts\Charts\ChartFactory;
use Khill\Lavacharts\DataTables\DataTable;
use Khill\Lavacharts\Exceptions\InvalidChartType;
Loading
Loading
@@ -81,7 +83,7 @@ class ChartBuilder extends GenericBuilder
* @param \Khill\Lavacharts\DataTables\DataTable $datatable
* @return self
*/
public function setDatatable(DataTable $datatable = null)
public function setDatatable(/*DataTable */$datatable = null)
{
$this->datatable = $datatable;
 
Loading
Loading
Loading
Loading
@@ -2,16 +2,19 @@
 
namespace Khill\Lavacharts\Charts;
 
use Khill\Lavacharts\Exceptions\BadMethodCallException;
use Khill\Lavacharts\Javascript\ChartJsFactory;
use Khill\Lavacharts\Support\Buffer;
use Khill\Lavacharts\Support\Contracts\Customizable;
use Khill\Lavacharts\Support\Contracts\DataInterface;
use Khill\Lavacharts\Support\Contracts\JavascriptSource;
use Khill\Lavacharts\Support\Contracts\JsFactory;
use Khill\Lavacharts\Support\Contracts\JsPackage;
use Khill\Lavacharts\Support\Contracts\Wrappable;
use Khill\Lavacharts\Support\Renderable;
use Khill\Lavacharts\Support\Traits\HasDataTableTrait as HasDataTable;
use Khill\Lavacharts\Support\Traits\HasOptionsTrait as HasOptions;
use Khill\Lavacharts\Support\Traits\ToJavascriptTrait as ToJavascript;
use Khill\Lavacharts\Values\ElementId;
use Khill\Lavacharts\Values\Label;
 
Loading
Loading
@@ -29,9 +32,11 @@ use Khill\Lavacharts\Values\Label;
* @link http://lavacharts.com Official Docs Site
* @license http://opensource.org/licenses/MIT MIT
*/
class Chart extends Renderable implements Customizable, DataInterface, JsFactory, Wrappable, JsPackage
class Chart
extends Renderable
implements Customizable, /*JavascriptSource,*/ JsFactory, JsPackage, Wrappable
{
use HasDataTable, HasOptions;
use HasDataTable, HasOptions/*, ToJavascript*/;
 
/**
* Javascript type.
Loading
Loading
@@ -57,7 +62,7 @@ class Chart extends Renderable implements Customizable, DataInterface, JsFactory
$this->setOptions($options);
 
$this->label = $label;
$this->datatable = $data->getDataTable();
$this->datatable = $data;
 
if ($this->options->has('elementId')) {
$this->elementId = new ElementId($this->options->elementId);
Loading
Loading
@@ -136,6 +141,12 @@ class Chart extends Renderable implements Customizable, DataInterface, JsFactory
*/
public function toArray()
{
if ( ! method_exists($this->datatable, 'getOptions')) {
throw new BadMethodCallException($this->datatable, 'getOptions');
}
$this->mergeOptions($this->datatable->getOptions());
return [
'pngOutput' => false,
'chartType' => $this->getType(),
Loading
Loading
@@ -194,7 +205,11 @@ class Chart extends Renderable implements Customizable, DataInterface, JsFactory
{
$buffer = new Buffer();
 
if (!$this->datatable->hasFormattedColumns()) {
if (!method_exists([$this->datatable], 'hasFormattedColumns')) {
// throw new BadMethodCallException($this->datatable, 'hasFormattedColumns');
// }
// if (!$this->datatable->hasFormattedColumns()) {
return $buffer;
}
 
Loading
Loading
@@ -214,7 +229,7 @@ class Chart extends Renderable implements Customizable, DataInterface, JsFactory
* Sets any configuration option, with no checks for type / validity
*
*
* This is method was added in 2.5 as a bandaid to remove the handcuffs from
* This is method was added in 2.5 as a band-aid to remove the handcuffs from
* users who want to add options that Google has added, that I have not.
* I didn't intend to restrict the user to only select options, as the
* goal was to type isNonEmpty and validate. This method can be used to set
Loading
Loading
Loading
Loading
@@ -5,6 +5,7 @@ namespace Khill\Lavacharts\Charts;
use \Khill\Lavacharts\Builders\ChartBuilder;
use Khill\Lavacharts\DataTables\DataTable;
use \Khill\Lavacharts\Exceptions\InvalidDataTable;
use Khill\Lavacharts\Support\Contracts\DataInterface;
 
/**
* ChartFactory Class
Loading
Loading
@@ -89,7 +90,7 @@ class ChartFactory
*/
public function create($type, $args)
{
if ($args[1] !== null && $args[1] instanceof DataTable === false) {
if ($args[1] !== null && $args[1] instanceof DataInterface === false) {
throw new InvalidDataTable;
}
 
Loading
Loading
Loading
Loading
@@ -48,13 +48,13 @@ class Event extends JavascriptSource
*/
public function toJavascript()
{
return sprintf($this->getFormatString(), $this->type, $this->callback);
return sprintf($this->getJsFormatString(), $this->type, $this->callback);
}
 
/**
* {@inheritdoc}
*/
public function getFormatString()
public function getJsFormatString()
{
/**
* In the scope of the events, "this" is a reference to the lavachart class.
Loading
Loading
Loading
Loading
@@ -49,7 +49,7 @@ class DateCell extends Cell
* @param string $format
* @param array $options
*/
public function __construct(Carbon $carbon = null, $format = '', array $options = [])
public function __construct(Carbon $carbon = null, $format = null, array $options = [])
{
parent::__construct($carbon, $format, $options);
}
Loading
Loading
@@ -67,7 +67,6 @@ class DateCell extends Cell
public static function createFromFormat($format, $datetime)
{
try {
var_dump($format);
$carbon = Carbon::createFromFormat($format, $datetime);
 
return new self($carbon);
Loading
Loading
Loading
Loading
@@ -88,10 +88,10 @@ class Column implements Customizable, Arrayable, Jsonable
{
$this->setOptions($options);
 
$this->type = $type;
$this->label = $label;
$this->type = $type;
$this->label = $label;
$this->format = $format;
$this->role = $role;
$this->role = $role;
}
 
/**
Loading
Loading
Loading
Loading
@@ -2,7 +2,10 @@
 
namespace Khill\Lavacharts\DataTables;
 
use Carbon\Carbon;
use DateTimeZone;
use Khill\Lavacharts\DataTables\Cells\Cell;
use Khill\Lavacharts\DataTables\Cells\DateCell;
use Khill\Lavacharts\DataTables\Columns\Column;
use Khill\Lavacharts\DataTables\Formats\Format;
use Khill\Lavacharts\Exceptions\InvalidArgumentException;
Loading
Loading
@@ -12,11 +15,11 @@ use Khill\Lavacharts\Exceptions\InvalidColumnIndex;
use Khill\Lavacharts\Exceptions\InvalidDateTimeFormat;
use Khill\Lavacharts\Exceptions\InvalidTimeZone;
use Khill\Lavacharts\Exceptions\UndefinedColumnsException;
use Khill\Lavacharts\Javascript\JavascriptSource;
use Khill\Lavacharts\Support\Contracts\Arrayable;
use Khill\Lavacharts\Support\Contracts\Customizable;
use Khill\Lavacharts\Support\Contracts\DataInterface;
use Khill\Lavacharts\Support\Contracts\Jsonable;
use Khill\Lavacharts\Support\Traits\ArrayToJsonTrait as ArrayToJson;
use Khill\Lavacharts\Support\Traits\HasOptionsTrait as HasOptions;
use Khill\Lavacharts\Values\Role;
use Khill\Lavacharts\Values\StringValue;
Loading
Loading
@@ -43,15 +46,14 @@ use Khill\Lavacharts\Values\StringValue;
* @link http://lavacharts.com Official Docs Site
* @license http://opensource.org/licenses/MIT MIT
*/
class DataTable implements DataInterface, Customizable, Arrayable, Jsonable
class DataTable extends JavascriptSource implements DataInterface, Customizable, Arrayable, Jsonable
{
use HasOptions, ArrayToJson;
use HasOptions;
 
/**
* Format string for sprintf to use with toJson and satisfy the
* implementation of DataInterface
* Format string for the default DataTable creation format.
*/
const JS_OUTPUT_FORMAT = 'new google.visualization.DataTable(%s)';
const DEFAULT_DATATABLE_FORMAT = 'new google.visualization.DataTable(%s)';
 
/**
* Array of the DataTable's column objects.
Loading
Loading
@@ -113,7 +115,8 @@ class DataTable implements DataInterface, Customizable, Arrayable, Jsonable
*
* Will include formats if defined
*
* @since 3.2.0 A boolean can be passed to disable the output of formatters.
* @since 3.2.0 A boolean can be passed to disable the output of formatters.
* @param bool $withFormats
* @return string JSON representation of the DataTable.
*/
public function toJson($withFormats = true)
Loading
Loading
@@ -133,7 +136,34 @@ class DataTable implements DataInterface, Customizable, Arrayable, Jsonable
*/
public function toJsDataTable()
{
return sprintf(self::JS_OUTPUT_FORMAT, $this->toJson(false));
return $this->toJavascript();
}
/**
* Return a format string that will be used by vsprintf to convert the
* extending class to javascript.
*
* @return string
*/
public function getJavascriptFormat()
{
return self::DEFAULT_DATATABLE_FORMAT;
}
/**
* Return an array of arguments to pass to the format string provided
* by getJavascriptFormat().
*
* These variables will be used with vsprintf, and the format string
* to convert the extending class to javascript.
*
* @return array
*/
public function getJavascriptSource()
{
return [
$this->toJson(false)
];
}
 
/**
Loading
Loading
@@ -506,34 +536,52 @@ class DataTable implements DataInterface, Customizable, Arrayable, Jsonable
* with null for the first two cells, you would specify [null, null, {cell_val}].
*
*
* @param array|null $valueArray Array of values describing cells or null for a null row.
* @param array|null $values Array of values describing cells or null for a null row.
* @return self
* @throws \Khill\Lavacharts\Exceptions\InvalidCellCount
* @throws \Khill\Lavacharts\Exceptions\UndefinedColumnsException
*/
public function addRow($valueArray)
public function addRow($values)
{
$columnCount = $this->getColumnCount();
$columnCount = $this->getColumnCount();
$columnTypes = $this->getColumnTypes();
 
if ($columnCount == 0) {
throw new UndefinedColumnsException;
}
 
if (is_null($valueArray)) {
if (is_null($values)) {
return $this->pushRow(Row::createNull($columnCount));
}
 
if (!is_array($valueArray)) {
throw new InvalidArgumentException($valueArray, 'array or null');
if (!is_array($values)) {
throw new InvalidArgumentException($values, 'array or null');
}
 
if (count($valueArray) > $columnCount) {
if (count($values) > $columnCount) {
throw new InvalidCellCount($columnCount);
}
 
$row = Row::createWith($this, $valueArray);
 
return $this->pushRow($row);
$rowData = [];
foreach ($values as $index => $cellValue) {
// Regardless of column type, if a Cell is explicitly defined by
// an array, then create a new Cell with the values.
if (is_array($cellValue)) {
$rowData[] = Cell::create($cellValue);
}
// Logic for handling datetime related cells
if (preg_match('/date|time|datetime|timeofday/', $columnTypes[$index])) {
$this->createDateCell($cellValue);
}
// Pass through any non-explicit & non-datetime values
$rowData[] = $cellValue;
}
return $this->pushRow(new Row($rowData));
}
 
/**
Loading
Loading
@@ -702,13 +750,19 @@ class DataTable implements DataInterface, Customizable, Arrayable, Jsonable
*/
public function getFormattedColumns()
{
return array_filter(array_map(function ($index, Column $column) {
if ($column->isFormatted()) {
$column->getFormat()->setIndex($index);
return array_filter(
array_map(
function ($index, Column $column) {
if ($column->isFormatted()) {
$column->getFormat()->setIndex($index);
 
return $column;
}
}, array_keys($this->cols), $this->cols));
return $column;
}
},
array_keys($this->cols),
$this->cols
)
);
}
 
/**
Loading
Loading
@@ -778,16 +832,52 @@ class DataTable implements DataInterface, Customizable, Arrayable, Jsonable
{
$timezoneList = call_user_func_array('array_merge', timezone_abbreviations_list());
 
$timezones = array_map(/** @noinspection PhpInconsistentReturnPointsInspection */
function ($timezone) {
if ($timezone['timezone_id'] != null) {
return strtolower($timezone['timezone_id']);
}
}, $timezoneList);
$timezones = array_map(
function ($timezone) {
if ($timezone['timezone_id'] != null) {
return strtolower($timezone['timezone_id']);
}
},
$timezoneList
);
 
$timezones = array_filter($timezones, 'is_string');
$timezones = array_unique($timezones);
 
return in_array(strtolower($tz), $timezones, true);
}
/**
* Create a new DateCell from the given value.
*
* @param $cellValue
* @return Cell
* @throws InvalidArgumentException
*/
private function createDateCell($cellValue)
{
$dateTimeFormat = $this->getOptions()->get('datetime_format');
// DateCells can only be created by Carbon instances or
// strings consumable by Carbon so....
if ($cellValue instanceof Carbon === false && is_string($cellValue) === false) {
throw new InvalidArgumentException($cellValue, 'string or Carbon object');
}
// If the cellValue is already a Carbon instance,
// create a new DateCell from it.
if ($cellValue instanceof Carbon) {
$rowData[] = new DateCell($cellValue);
}
// If no format string was defined in the options, then
// attempt to implicitly parse the string. If the format
// string is not empty, then attempt to use it to explicitly
// create a Carbon instance from the format.
if (!empty($dateTimeFormat)) {
$rowData[] = DateCell::createFromFormat($dateTimeFormat, $cellValue);
}
return DateCell::create($cellValue);
}
}
Loading
Loading
@@ -111,7 +111,7 @@ class Format extends JavascriptSource implements Customizable
public function toJavascript()
{
return sprintf(
$this->getFormatString(),
$this->getJsFormatString(),
$this->index,
$this->getJsClass(),
$this->options
Loading
Loading
@@ -121,7 +121,7 @@ class Format extends JavascriptSource implements Customizable
/**
* @inheritdoc
*/
public function getFormatString()
public function getJsFormatString()
{
/**
* In the scope of the formats, "this" is a reference to the lavachart class.
Loading
Loading
Loading
Loading
@@ -2,13 +2,17 @@
 
namespace Khill\Lavacharts\DataTables;
 
use Khill\Lavacharts\Javascript\JavascriptSource;
use Khill\Lavacharts\Support\Contracts\DataInterface;
use Khill\Lavacharts\Support\Contracts\JavascriptSource;
use Khill\Lavacharts\Support\Traits\HasOptionsTrait as HasOptions;
use Khill\Lavacharts\Support\Traits\ToJavascriptTrait as ToJavascript;
 
class JoinedDataTable extends JavascriptSource implements DataInterface
class JoinedDataTable implements DataInterface, JavascriptSource
{
use HasOptions, ToJavascript;
/**
* Array of joined tables
* Array of DataTables to join.
*
* @var DataTable[]
*/
Loading
Loading
@@ -17,13 +21,18 @@ class JoinedDataTable extends JavascriptSource implements DataInterface
/**
* JoinedDataTable constructor.
*
* @param \Khill\Lavacharts\Support\Contracts\DataInterface $data1
* @param \Khill\Lavacharts\Support\Contracts\DataInterface $data2
* @param DataTable $data1
* @param DataTable $data2
*/
public function __construct(DataInterface $data1, DataInterface $data2)
public function __construct(DataTable $data1, DataTable $data2, array $options = [])
{
$this->tables[] = $data1->getDataTable();
$this->tables[] = $data2->getDataTable();
$this->initOptions($options);
$this->options->set('interpolateNulls', true);
$this->options->setIfNot('joinMethod', 'full');
$this->tables = [$data1, $data2];
}
 
/**
Loading
Loading
@@ -32,19 +41,37 @@ class JoinedDataTable extends JavascriptSource implements DataInterface
*
* @return string
*/
public function toJavascript()
public function toJsDataTable()
{
return sprintf($this->getFormatString(), $this->tables[0], $this->tables[1]);
return $this->toJavascript();
}
 
/**
* Return a format string that will be used by sprintf to convert the
* extending class to javascript.
* Get the format string that will be used by sprintf and toJson()
* to convert the extending class to javascript.
*
* @return string
*/
public function getFormatString()
public function getJavascriptFormat()
{
return 'google.visualization.data.join(%s, %s, "full", [[0, 0]], [1], [1])';
return 'google.visualization.data.join(%s, %s, "%s", [[0, 0]], [1], [1])';
}
/**
* Return an array of arguments to pass to the format string provided
* by getJavascriptFormat().
*
* These variables will be used with vsprintf, and the format string
* to convert the extending class to javascript.
*
* @return array
*/
public function getJavascriptSource()
{
$sourceVars = $this->tables;
array_push($sourceVars, $this->options->joinMethod);
return $sourceVars;
}
}
Loading
Loading
@@ -48,70 +48,13 @@ class Row implements Arrayable, ArrayAccess, Countable, Jsonable
*/
public static function createNull($columnCount)
{
if ( ! is_int($columnCount)) {
if (!is_int($columnCount)) {
throw new InvalidArgumentException($columnCount, 'integer');
}
 
return new self(array_fill(0, $columnCount, null));
}
 
/**
* Creates a new Row object from an array of values.
*
* @param DataInterface $data
* @param array $values Array of values to assign to the row.
* @return Row
* @throws \Khill\Lavacharts\Exceptions\UndefinedDateCellException
* @throws \Khill\Lavacharts\Exceptions\InvalidDateTimeString
*/
public static function createWith(DataInterface $data, $values)
{
$datatable = $data->getDataTable();
$columnTypes = $datatable->getColumnTypes();
$dateTimeFormat = $datatable->getOptions()->get('datetime_format');
$rowData = [];
foreach ($values as $index => $cellValue) {
// Regardless of column type, if a Cell is explicitly defined by
// an array, then create a new Cell with the values.
if (is_array($cellValue)) {
$rowData[] = Cell::create($cellValue);
}
// Logic for handling datetime related cells
if (preg_match('/date|time|datetime|timeofday/', $columnTypes[$index])) {
// DateCells can only be created by Carbon instances or
// strings consumable by Carbon so....
if ($cellValue instanceof Carbon === false && is_string($cellValue) === false) {
throw new InvalidArgumentException($cellValue, 'string or Carbon object');
}
// If the cellValue is already a Carbon instance,
// create a new DateCell from it.
if ($cellValue instanceof Carbon) {
$rowData[] = new DateCell($cellValue);
}
// If no format string was defined in the options, then
// attempt to implicitly parse the string. If the format
// string is not empty, then attempt to use it to explicitly
// create a Carbon instance from the format.
if (empty($dateTimeFormat)) {
$rowData[] = DateCell::create($cellValue);
} else {
$rowData[] = DateCell::createFromFormat($dateTimeFormat, $cellValue);
}
}
// Pass through any non-explicit & non-datetime values
$rowData[] = $cellValue;
}
return new self($rowData);
}
/**
* Creates a new Row object with the given values from an array.
*
Loading
Loading
<?php
namespace Khill\Lavacharts\Exceptions;
class BadMethodCallException extends LavaException
{
public function __construct($object, $method)
{
$message = '"%s" is not a valid method on "%s"';
parent::__construct(sprintf($message, $method, get_class($object)));
}
}
Loading
Loading
@@ -2,7 +2,7 @@
 
namespace Khill\Lavacharts\Exceptions;
 
class InvalidArgumentException extends \InvalidArgumentException
class InvalidArgumentException extends LavaException
{
public function __construct($actual, $expected)
{
Loading
Loading
Loading
Loading
@@ -43,11 +43,11 @@ class ChartJsFactory extends JavascriptFactory
*/
public function __construct(Chart $chart)
{
$this->chart = $chart;
$this->chart = $chart;
$this->template = self::JS_TEMPLATE;
$this->templateVars = $this->getTemplateVars();
 
parent::__construct(self::JS_TEMPLATE, $this->getTemplateVars());
parent::__construct();
}
 
/**
Loading
Loading
Loading
Loading
@@ -28,7 +28,7 @@ class DashboardJsFactory extends JavascriptFactory
*
* @var string
*/
const OUTPUT_TEMPLATE = 'dashboard.tmpl.js';
const JS_TEMPLATE = 'dashboard.tmpl.js';
 
/**
* Dashboard to generate javascript from.
Loading
Loading
@@ -45,8 +45,9 @@ class DashboardJsFactory extends JavascriptFactory
public function __construct(Dashboard $dashboard)
{
$this->dashboard = $dashboard;
$this->template = self::JS_TEMPLATE;
 
parent::__construct(self::OUTPUT_TEMPLATE);
parent::__construct();
}
 
/**
Loading
Loading
Loading
Loading
@@ -45,16 +45,11 @@ class JavascriptFactory
 
/**
* JavascriptFactory constructor.
*
* @param string $jsTemplate
* @param array $templateVars
*/
public function __construct($jsTemplate, array $templateVars)
public function __construct()
{
$this->templateVars = $templateVars;
$this->template = file_get_contents(
realpath(__DIR__ . '/../../javascript/templates/' . $jsTemplate)
realpath(__DIR__ . '/../../javascript/templates/' . $this->template)
);
 
$this->buffer = new Buffer($this->template);
Loading
Loading
Loading
Loading
@@ -7,6 +7,8 @@ use Khill\Lavacharts\Support\Contracts\Javascriptable;
/**
* JavascriptSource Class
*
* Define how an instance of an object will be converted to javascript source.
*
* @package Khill\Lavacharts\Support
* @since 3.2.0
* @author Kevin Hill <kevinkhill@gmail.com>
Loading
Loading
@@ -15,27 +17,41 @@ use Khill\Lavacharts\Support\Contracts\Javascriptable;
* @link http://lavacharts.com Official Docs Site
* @license http://opensource.org/licenses/MIT MIT
*/
abstract class JavascriptSource implements Javascriptable
abstract class JavascriptSource
{
/**
* Define how the class will be cast to javascript source when
* the extending class is treated like a string.
* Return a format string that will be used by vsprintf to convert the
* extending class to javascript.
*
* @return string
*/
public abstract function toJavascript();
abstract public function getJavascriptFormat();
 
/**
* Return a format string that will be used by sprintf to convert the
* extending class to javascript.
* Return an array of arguments to pass to the format string provided
* by getJavascriptFormat().
*
* These variables will be used with vsprintf, and the format string
* to convert the extending class to javascript.
*
* @return array
*/
abstract public function getJavascriptSource();
/**
* Using the format provided and the source variables, transform the instance
* to javascript source.
*
* @return string
*/
public abstract function getFormatString();
public function toJavascript()
{
return vsprintf($this->getJavascriptFormat(), $this->getJavascriptSource());
}
 
/**
* When accessing as a string, the instance will converted to
* javascript source.
* When accessing as a string, the instance will converted to javascript source.
*
* @return string
*/
Loading
Loading
Loading
Loading
@@ -10,7 +10,7 @@ namespace Khill\Lavacharts\Support\Contracts;
* Example:
* The standard DataTable class which will use this method to convert
* the DataTable into JSON and then simply create a new DataTable in javascript
* with "new google.visualization.DataTable(JSON_HERE)"
* with "new google.visualization.DataTable(%s)"
*
* Another Example:
* This was pulled straight from Google's SteppedAreaChart) would be to
Loading
Loading
<?php
namespace Khill\Lavacharts\Support\Contracts;
/**
* JavascriptSource Interface
*
* Define how an instance of an object will be converted to javascript source.
*
* @package Khill\Lavacharts\Support\Contracts
* @since 3.2.0
* @author Kevin Hill <kevinkhill@gmail.com>
* @copyright (c) 2017, KHill Designs
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
* @link http://lavacharts.com Official Docs Site
* @license http://opensource.org/licenses/MIT MIT
*/
interface JavascriptSource
{
/**
* Return a format string that will be used by vsprintf to convert the
* extending class to javascript.
*
* @return string
*/
public function getJavascriptFormat();
/**
* Return an array of arguments to pass to the format string provided
* by getJavascriptFormat().
*
* These variables will be used with vsprintf, and the format string
* to convert the extending class to javascript.
*
* @return array
*/
public function getJavascriptSource();
}
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