DataTable
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
Creates a new DataTable
Sets the Timezone that Carbon will use when parsing dates
Sets the format to be used by Carbon::createFromFormat()
Adds a column to the DataTable
Adds multiple columns to the DataTable
Supplemental function to add a string column with less params.
Supplemental function to add a date column with less params.
Supplemental function to add a number column with less params.
Sets the format of the column.
Sets the format of multiple columns.
Returns the number of columns in the DataTable
Returns the number of rows in the DataTable
Returns the column array from the DataTable
Returns the rows array from the DataTable
Returns the types of columns currently defined.
Returns the column number of the ypes of columns currently defined.
Returns the formats array from the DataTable
Boolean value if there are defined formatters
Convert the DataTable to JSON
Details
        at line 110
                            
    DataTable
    __construct(
    string $timezone = null)
    
    Creates a new 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
        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()
        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.
        at line 217
                            
    DataTable
    addColumns(
    array $arrOfCols)
    
    Adds multiple columns to the DataTable
        at line 243
                            
    DataTable
    addStringColumn(
    string $optLabel, 
    Format $formatter = null)
    
    Supplemental function to add a string column with less params.
        at line 258
                            
    DataTable
    addDateColumn(
    string $optLabel, 
    Format $formatter = null)
    
    Supplemental function to add a date column with less params.
        at line 273
                            
    DataTable
    addNumberColumn(
    string $optLabel, 
    Format $formatter = null)
    
    Supplemental function to add a number column with less params.
        at line 287
                            
    DataTable
    formatColumn(
    int $colIndex, 
    Format $formatter)
    
    Sets the format of the column.
        at line 305
                            
    DataTable
    formatColumns(
    array $colFormatArr)
    
    Sets the format of multiple columns.
        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}].
        at line 404
                            
    DataTable
    addRows(
    array $arrayOfRows)
    
    Adds multiple rows to the DataTable.
        at line 426
                            
    int
    getNumberOfColumns()
    
    Returns the number of columns in the DataTable
        at line 437
                            
    int
    getNumberOfRows()
    
    Returns the number of rows in the DataTable
        at line 448
                            
    array
    getColumns()
    
    Returns the column array from the DataTable
        at line 459
                            
    array
    getRows()
    
    Returns the rows array from the DataTable
        at line 471
                            
    array
    getColumnTypes()
    
    Returns the types of columns currently defined.
        at line 490
                            
    int|bool
    getColumnIndexByType($type)
    
    Returns the column number of the ypes of columns currently defined.
        at line 501
                            
    array
    getFormats()
    
    Returns the formats array from the DataTable
        at line 512
                            
    bool
    hasFormats()
    
    Boolean value if there are defined formatters
        at line 523
                            
    string
    toJson()
    
    Convert the DataTable to JSON