class DataTable (View source)

Properties

string $timezone Timezone for dealing with datetime and Carbon objects
string $dateTimeFormat Timezone for dealing with datetime and Carbon objects

Methods

__construct( string $timezone = null)

Creates a new DataTable

setTimezone( string $timezone)

Sets the Timezone that Carbon will use when parsing dates

setDateTimeFormat( string $dateTimeFormat)

Sets the format to be used by Carbon::createFromFormat()

addColumn( string|array $typeOrDescArr, string $optLabel = '', string $optId = '', Format $formatter = null, string $role = '')

Adds a column to the DataTable

addColumns( array $arrOfCols)

Adds multiple columns to the DataTable

addStringColumn( string $optLabel, Format $formatter = null)

Supplemental function to add a string column with less params.

addDateColumn( string $optLabel, Format $formatter = null)

Supplemental function to add a date column with less params.

addNumberColumn( string $optLabel, Format $formatter = null)

Supplemental function to add a number column with less params.

formatColumn( int $colIndex, Format $formatter)

Sets the format of the column.

formatColumns( array $colFormatArr)

Sets the format of multiple columns.

addRow( mixed $optCellArray = null)

Add a row to the DataTable

addRows( array $arrayOfRows)

Adds multiple rows to the DataTable.

int
getNumberOfColumns()

Returns the number of columns in the DataTable

int
getNumberOfRows()

Returns the number of rows in the DataTable

array
getColumns()

Returns the column array from the DataTable

array
getRows()

Returns the rows array from the DataTable

array
getColumnTypes()

Returns the types of columns currently defined.

int|bool
getColumnIndexByType($type)

Returns the column number of the ypes of columns currently defined.

array
getFormats()

Returns the formats array from the DataTable

bool
hasFormats()

Boolean value if there are defined formatters

string
toJson()

Convert the DataTable to JSON

Details

at line 110
DataTable __construct( string $timezone = null)

Creates a new DataTable

Parameters

string $timezone

Return Value

DataTable

at line 125
DataTable setTimezone( string $timezone)

Sets the Timezone that Carbon will use when parsing dates

This will use the passed timezone, falling back to the default from php.ini, and falling back from that to America/Los_Angeles

Parameters

string $timezone

Return Value

DataTable

at line 153
DataTable setDateTimeFormat( string $dateTimeFormat)

Sets the format to be used by Carbon::createFromFormat()

This method is used to set the format to be used to parse a string passed to a cell in a date column, that was parsed incorrectly by Carbon::parse()

Parameters

string $dateTimeFormat

Return Value

DataTable

at line 193
DataTable addColumn( string|array $typeOrDescArr, string $optLabel = '', string $optId = '', Format $formatter = null, string $role = '')

Adds a column to the DataTable

First signature has the following parameters: type - A string with the data type of the values of the column. The type can be one of the following: 'string' 'number' 'bool' 'date' 'datetime' 'timeofday'.

optLabel - [Optional] A string with the label of the column. The column label is typically displayed as part of the visualization, for example as a column header in a table, or as a legend label in a pie chart. If not value is specified, an empty string is assigned. optId - [Optional] A string with a unique identifier for the column. If not value is specified, an empty string is assigned.

Parameters

string|array $typeOrDescArr Column type or an array describing the column.
string $optLabel A label for the column. (Optional)
string $optId An ID for the column. (Optional)
Format $formatter A column formatter object. (Optional)
string $role A role for the column. (Optional)

Return Value

DataTable

Exceptions

InvalidConfigValue
InvalidConfigProperty

at line 217
DataTable addColumns( array $arrOfCols)

Adds multiple columns to the DataTable

Parameters

array $arrOfCols Array of columns to batch add to the DataTable.

Return Value

DataTable

Exceptions

InvalidConfigValue

at line 243
DataTable addStringColumn( string $optLabel, Format $formatter = null)

Supplemental function to add a string column with less params.

Parameters

string $optLabel A label for the column.
Format $formatter A column formatter object. (Optional)

Return Value

DataTable

Exceptions

InvalidConfigValue
InvalidConfigProperty

at line 258
DataTable addDateColumn( string $optLabel, Format $formatter = null)

Supplemental function to add a date column with less params.

Parameters

string $optLabel A label for the column.
Format $formatter A column formatter object. (Optional)

Return Value

DataTable

Exceptions

InvalidConfigValue
InvalidConfigProperty

at line 273
DataTable addNumberColumn( string $optLabel, Format $formatter = null)

Supplemental function to add a number column with less params.

Parameters

string $optLabel A label for the column.
Format $formatter A column formatter object. (Optional)

Return Value

DataTable

Exceptions

InvalidConfigValue
InvalidConfigProperty

at line 287
DataTable formatColumn( int $colIndex, Format $formatter)

Sets the format of the column.

Parameters

int $colIndex
Format $formatter

Return Value

DataTable

Exceptions

InvalidColumnIndex

at line 305
DataTable formatColumns( array $colFormatArr)

Sets the format of multiple columns.

Parameters

array $colFormatArr

Return Value

DataTable

at line 349
DataTable addRow( mixed $optCellArray = null)

Add a row to the DataTable

Each cell in the table is described by an array with the following properties:

v [Optional] The cell value. The data type should match the column data type. If null, the whole object should be empty and have neither v nor f properties.

f [Optional] A string version of the v value, formatted for display. The values should match, so if you specify Date(2008, 0, 1) for v, you should specify "January 1, 2008" or some such string for this property. This value is not checked against the v value. The visualization will not use this value for calculation, only as a label for display. If omitted, a string version of v will be used.

p [Optional] An object that is a map of custom values applied to the cell. These values can be of any JavaScript type. If your visualization supports any cell-level properties, it will describe them; otherwise, this property will be ignored. Example: p:{style: 'border: 1px solid green;'}.

Cells in the row array should be in the same order as their column descriptions in cols. To indicate a null cell, you can specify null, leave a blank for a cell in an array, or omit trailing array members. So, to indicate a row with null for the first two cells, you would specify [null, null, {cell_val}].

Parameters

mixed $optCellArray Array of values or DataCells.

Return Value

DataTable

Exceptions

InvalidCellCount

at line 404
DataTable addRows( array $arrayOfRows)

Adds multiple rows to the DataTable.

Parameters

array $arrayOfRows Multi-dimensional array of rows.

Return Value

DataTable

See also

addRow()

at line 426
int getNumberOfColumns()

Returns the number of columns in the DataTable

Return Value

int

at line 437
int getNumberOfRows()

Returns the number of rows in the DataTable

Return Value

int

at line 448
array getColumns()

Returns the column array from the DataTable

Return Value

array

at line 459
array getRows()

Returns the rows array from the DataTable

Return Value

array

at line 471
array getColumnTypes()

Returns the types of columns currently defined.

Return Value

array

at line 490
int|bool getColumnIndexByType($type)

Returns the column number of the ypes of columns currently defined.

Parameters

$type

Return Value

int|bool Column index on success, false on failure.

at line 501
array getFormats()

Returns the formats array from the DataTable

Return Value

array

at line 512
bool hasFormats()

Boolean value if there are defined formatters

Return Value

bool

at line 523
string toJson()

Convert the DataTable to JSON

Return Value

string JSON representation of the DataTable.