class TableChart extends Chart (View source)

Constants

TYPE

Javascript chart type.

VERSION

Javascript chart version.

VIZ_PACKAGE

Javascript chart package.

VIZ_CLASS

Google's visualization class name.

Methods

__construct( Label $chartLabel, DataTable $datatable, array $config = array())

Builds a new TableChart with the given label, datatable and options.

mixed
__get( string $option)

Get the value of a set option via magic method.

from  JsonConfig
getOptions()

Gets the Options object for the JsonConfig

from  JsonConfig
setOption( string $option, mixed $value)

Shortcut method to set the value of an option and return $this.

from  JsonConfig
setOptions( array $config)

Parses the config array by passing the values through each method to check validity against if the option exists.

from  JsonConfig
array
jsonSerialize()

Custom serialization of the JsonConfig object.

from  JsonConfig
string
getType()

Returns the chart type.

from  Chart
bool
hasEvents()

Checks if any events have been assigned to the chart.

from  Chart
getEvents()

Retrieves the events if any have been assigned to the chart.

from  Chart
getLabel()

Returns the chart label.

from  Chart
events( array $events)

Register javascript callbacks for specific events.

from  Chart
datatable( DataTable $datatable)

Assigns a datatable to use for the Chart.

from  Chart
customize( array $optionArray)

Sets any configuration option, with no checks for type / validity

from  Chart
getDataTable()

Returns the DataTable

from  Chart
string
getDataTableJson()

Returns a JSON string representation of the datatable.

from  Chart
string
render( string $elemId)

Outputs the chart javascript into the page.

from  Chart
animation( array $animationConfig)

Set the animation options for a chart.

from  Chart
backgroundColor( array $backgroundColorConfig)

The background color for the main area of the chart.

from  Chart
chartArea( array $chartAreaConfig)

An object with members to configure the placement and size of the chart area (where the chart itself is drawn, excluding axis and legends).

from  Chart
colors( array $colorArray)

The colors to use for the chart elements.

from  Chart
fontSize( integer $fontSize)

The default font size, in pixels, of all text in the chart.

from  Chart
fontName( string $fontName)

The default font face for all text in the chart.

from  Chart
height( int $height)

Height of the chart, in pixels.

from  Chart
legend( array $legendConfig)

An object with members to configure various aspects of the legend.

from  Chart
title( string $title)

Text to display above the chart.

from  Chart
titlePosition( string $titlePosition)

Where to place the chart title, compared to the chart area.

from  Chart
titleTextStyle( TextStyle $textStyle)

An array of options for defining the title text style.

from  Chart
tooltip( array $tooltip)

An object with members to configure various tooltip elements.

from  Chart
width( int $width)

Width of the chart, in pixels.

from  Chart
allowHtml( bool $html)

If set to true the GoogleChart will render html tags sorted as values.

alternatingRowStyle( bool $astyle)

If set to true the GoogleChart will alternate the role styles.

cssClassNames( array $classNameConfig)

An object in which each property name describes a table element, and the property value is a string, defining a class to assign to that table element.

firstRowNumber( int $firstRowNumber)

The row number for the first row in the dataTable. Used only if showRowNumber is true.

frozenColumns( int $frozenColumns)

The number of columns from the left that will be frozen.

page( string $page)

If and how to enable paging through the data.

pageSize( int $pageSize)

The number of rows in each page, when paging is enabled with the page option.

pagingButtons( string|int $paging)

Sets a specified option for the paging buttons. The options are as follows: both - enable prev and next buttons prev - only prev button is enabled next - only next button is enabled auto - the buttons are enabled according to the current page. On the first page only next is shown. On the last page only prev is shown. Otherwise both are enabled.

rtlTable( bool $rtl)

Adds basic support for right-to-left languages (such as Arabic or Hebrew) by reversing the column order of the table, so that column zero is the rightmost column, and the last column is the leftmost column. This does not affect the column index in the underlying data, only the order of display. Full bi-directional (BiDi) language display is not supported by the table visualization even with this option. This option will be ignored if you enable paging (using the page option), or if the table has scroll bars because you have specified height and width options smaller than the required table size.

scrollLeftStartPosition( int $startPosition)

Sets the horizontal scrolling position, in pixels, if the table has horizontal scroll bars because you have set the width property. The table will open scrolled that many pixels past the leftmost column.

showRowNumber( bool $rowNumber)

If set to true, shows the row number as the first column of the table.

sortTable( string $sort)

If and how to sort columns when the user clicks a column heading. If sorting is enabled, consider setting the sortAscending and sortColumn properties as well. Choose one of the following string values: 'enable' - [Default] Users can click on column headers to sort by the clicked column. When users click on the column header, the rows will be automatically sorted, and a 'sort' event will be triggered.

sortAscending( bool $sort)

The order in which the initial sort column is sorted. True for ascending, false for descending. Ignored if sortColumn is not specified.

sortColumn( int $sort)

An index of a column in the data table, by which the table is initially sorted.

startPage( int $start)

The first table page to display. Used only if page is in mode enable/event.

Details

at line 87
__construct( Label $chartLabel, DataTable $datatable, array $config = array())

Builds a new TableChart with the given label, datatable and options.

Parameters

Label $chartLabel Identifying label for the chart.
DataTable $datatable DataTable used for the chart.
array $config

Exceptions

InvalidConfigValue

in JsonConfig at line 64
mixed __get( string $option)

Get the value of a set option via magic method.

Parameters

string $option Name of option.

Return Value

mixed

Exceptions

InvalidConfigProperty

in JsonConfig at line 75
Options getOptions()

Gets the Options object for the JsonConfig

Return Value

Options

in JsonConfig at line 90
JsonConfig setOption( string $option, mixed $value)

Shortcut method to set the value of an option and return $this.

In order to maintain backwards compatibility, ConfigObjects will be unwrapped.

Parameters

string $option Option to set.
mixed $value Value of the option.

Return Value

JsonConfig

in JsonConfig at line 106
setOptions( array $config)

Parses the config array by passing the values through each method to check validity against if the option exists.

Parameters

array $config

Exceptions

InvalidConfigValue
InvalidConfigProperty

in JsonConfig at line 275
array jsonSerialize()

Custom serialization of the JsonConfig object.

Return Value

array

in Chart at line 111
string getType()

Returns the chart type.

Return Value

string

in Chart at line 122
bool hasEvents()

Checks if any events have been assigned to the chart.

Return Value

bool

in Chart at line 133
EventManager getEvents()

Retrieves the events if any have been assigned to the chart.

Return Value

EventManager

in Chart at line 145
Label getLabel()

Returns the chart label.

Return Value

Label

in Chart at line 164
Chart events( array $events)

Register javascript callbacks for specific events.

Set with an associative array where the keys are events and the values are the javascript callback functions.

Valid events are: [ animationfinish | error | onmouseover | onmouseout | ready | select | statechange ]

Parameters

array $events Array of events associated to a callback

Return Value

Chart

Exceptions

InvalidConfigValue

in Chart at line 196
Chart datatable( DataTable $datatable)

Assigns a datatable to use for the Chart.

Parameters

DataTable $datatable

Return Value

Chart

in Chart at line 221
Chart customize( array $optionArray)

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 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 check and validate. This method can be used to set any option, just pass in arrays with key value pairs for any setting.

If the setting is an object, per the google docs, then use multi-dimensional arrays and they will be converted upon rendering.

Parameters

array $optionArray Array of customization options for the chart

Return Value

Chart

in Chart at line 234
DataTable getDataTable()

Returns the DataTable

Return Value

DataTable

Exceptions

DataTableNotFound

in Chart at line 251
string getDataTableJson()

Returns a JSON string representation of the datatable.

Return Value

string

Exceptions

DataTableNotFound

in Chart at line 271
string render( string $elemId)

Outputs the chart javascript into the page.

Pass in a string of the html elementID that you want the chart to be rendered into.

Parameters

string $elemId The id of an HTML element to render the chart into.

Return Value

string Javascript code blocks

Exceptions

InvalidElementId

in Chart at line 290
Chart animation( array $animationConfig)

Set the animation options for a chart.

Parameters

array $animationConfig Animation options

Return Value

Chart

in Chart at line 304
Chart backgroundColor( array $backgroundColorConfig)

The background color for the main area of the chart.

Can be a simple HTML color string, or hex code, for example: 'red' or '#00cc00'

Parameters

array $backgroundColorConfig Options for the chart's background color

Return Value

Chart

in Chart at line 321
Chart chartArea( array $chartAreaConfig)

An object with members to configure the placement and size of the chart area (where the chart itself is drawn, excluding axis and legends).

Two formats are supported: a number, or a number followed by %. A simple number is a value in pixels; a number followed by % is a percentage.

Parameters

array $chartAreaConfig Options for the chart area.

Return Value

Chart

in Chart at line 338
Chart colors( array $colorArray)

The colors to use for the chart elements.

An array of strings, where each element is an HTML color string for example:['red','#004411']

Parameters

array $colorArray

Return Value

Chart

Exceptions

InvalidConfigValue

in Chart at line 362
Chart fontSize( integer $fontSize)

The default font size, in pixels, of all text in the chart.

You can override this using properties for specific chart elements.

Parameters

integer $fontSize

Return Value

Chart

Exceptions

InvalidConfigValue

in Chart at line 378
Chart fontName( string $fontName)

The default font face for all text in the chart.

You can override this using properties for specific chart elements.

Parameters

string $fontName

Return Value

Chart

Exceptions

InvalidConfigValue

in Chart at line 392
Chart height( int $height)

Height of the chart, in pixels.

Parameters

int $height

Return Value

Chart

Exceptions

InvalidConfigValue

in Chart at line 408
Chart legend( array $legendConfig)

An object with members to configure various aspects of the legend.

To specify properties of this object, pass in an array of valid options.

Parameters

array $legendConfig Options for the chart's legend.

Return Value

Chart

Exceptions

InvalidConfigValue

in Chart at line 422
Chart title( string $title)

Text to display above the chart.

Parameters

string $title

Return Value

Chart

Exceptions

InvalidConfigValue

in Chart at line 441
Chart titlePosition( string $titlePosition)

Where to place the chart title, compared to the chart area.

Supported values: 'in' - Draw the title inside the chart area. 'out' - Draw the title outside the chart area. 'none' - Omit the title.

Parameters

string $titlePosition

Return Value

Chart

Exceptions

InvalidConfigValue

in Chart at line 461
Chart titleTextStyle( TextStyle $textStyle)

An array of options for defining the title text style.

Parameters

TextStyle $textStyle

Return Value

Chart

Exceptions

InvalidConfigValue

in Chart at line 474
Chart tooltip( array $tooltip)

An object with members to configure various tooltip elements.

Parameters

array $tooltip Options for the tooltips

Return Value

Chart

Exceptions

InvalidConfigValue

in Chart at line 486
Chart width( int $width)

Width of the chart, in pixels.

Parameters

int $width

Return Value

Chart

Exceptions

InvalidConfigValue

at line 102
TableChart allowHtml( bool $html)

If set to true the GoogleChart will render html tags sorted as values.

Parameters

bool $html

Return Value

TableChart

Exceptions

InvalidConfigValue

at line 115
TableChart alternatingRowStyle( bool $astyle)

If set to true the GoogleChart will alternate the role styles.

Parameters

bool $astyle

Return Value

TableChart

Exceptions

InvalidConfigValue

at line 148
TableChart cssClassNames( array $classNameConfig)

An object in which each property name describes a table element, and the property value is a string, defining a class to assign to that table element.

Use this property to assign custom CSS to specific elements of your table. To use this property, assign an object, where the property name specifies the table element, and the property value is a string, specifying a class name to assign to that element. You must then define a CSS style for that class on your page. The following property names are supported: headerRow - Assigns a class name to the table header row ( element). tableRow - Assigns a class name to the non-header rows ( elements). oddTableRow - Assigns a class name to odd table rows ( elements). Note: the alternatingRowStyle option must be set to true. selectedTableRow - Assigns a class name to the selected table row ( element). hoverTableRow - Assigns a class name to the hovered table row ( element). headerCell - Assigns a class name to all cells in the header row ( element). tableCell - Assigns a class name to all non-header table cells ( element). rowNumberCell - Assigns a class name to the cells in the row number column ( element). Note: the showRowNumber option must be set to true.

Example: var cssClassNames = {headerRow: 'bigAndBoldClass', hoverTableRow: 'highlightClass'};

Parameters

array $classNameConfig

Return Value

TableChart

Exceptions

InvalidConfigValue

at line 162
TableChart firstRowNumber( int $firstRowNumber)

The row number for the first row in the dataTable. Used only if showRowNumber is true.

Parameters

int $firstRowNumber

Return Value

TableChart

Exceptions

InvalidConfigValue

at line 180
TableChart frozenColumns( int $frozenColumns)

The number of columns from the left that will be frozen.

These columns will remain in place when scrolling the remaining columns horizontally. If showRowNumber is false, setting frozenColumns to 0 will appear the same as if set to null, but if showRowNumber is set to true, the row number column will be frozen.

Parameters

int $frozenColumns

Return Value

TableChart

Exceptions

InvalidConfigValue

at line 202
TableChart page( string $page)

If and how to enable paging through the data.

Choose one of the following string values: 'enable' - The table will include page-forward and page-back buttons. Clicking on these buttons will perform the paging operation and change the displayed page. You might want to also set the pageSize option. 'event' - The table will include page-forward and page-back buttons, but clicking them will trigger a 'page' event and will not change the displayed page. This option should be used when the code implements its own page turning logic. See the TableQueryWrapper example for an example of how to handle paging events manually. 'disable' - [Default] Paging is not supported.

Parameters

string $page

Return Value

TableChart

Exceptions

InvalidConfigValue

at line 232
TableChart pageSize( int $pageSize)

The number of rows in each page, when paging is enabled with the page option.

Parameters

int $pageSize

Return Value

TableChart

Exceptions

InvalidConfigValue

at line 252
TableChart pagingButtons( string|int $paging)

Sets a specified option for the paging buttons. The options are as follows: both - enable prev and next buttons prev - only prev button is enabled next - only next button is enabled auto - the buttons are enabled according to the current page. On the first page only next is shown. On the last page only prev is shown. Otherwise both are enabled.

number - the number of paging buttons to show. This explicit number will override computed number from pageSize.

Parameters

string|int $paging

Return Value

TableChart

Exceptions

InvalidConfigValue

at line 286
TableChart rtlTable( bool $rtl)

Adds basic support for right-to-left languages (such as Arabic or Hebrew) by reversing the column order of the table, so that column zero is the rightmost column, and the last column is the leftmost column. This does not affect the column index in the underlying data, only the order of display. Full bi-directional (BiDi) language display is not supported by the table visualization even with this option. This option will be ignored if you enable paging (using the page option), or if the table has scroll bars because you have specified height and width options smaller than the required table size.

Parameters

bool $rtl

Return Value

TableChart

Exceptions

InvalidConfigValue

at line 300
TableChart scrollLeftStartPosition( int $startPosition)

Sets the horizontal scrolling position, in pixels, if the table has horizontal scroll bars because you have set the width property. The table will open scrolled that many pixels past the leftmost column.

Parameters

int $startPosition

Return Value

TableChart

Exceptions

InvalidConfigValue

at line 313
TableChart showRowNumber( bool $rowNumber)

If set to true, shows the row number as the first column of the table.

Parameters

bool $rowNumber

Return Value

TableChart

Exceptions

InvalidConfigValue

at line 333
TableChart sortTable( string $sort)

If and how to sort columns when the user clicks a column heading. If sorting is enabled, consider setting the sortAscending and sortColumn properties as well. Choose one of the following string values: 'enable' - [Default] Users can click on column headers to sort by the clicked column. When users click on the column header, the rows will be automatically sorted, and a 'sort' event will be triggered.

'event' - When users click on the column header, a 'sort' event will be triggered, but the rows will not be automatically sorted. This option should be used when the page implements its own sort. See the TableQueryWrapper example for an example of how to handle sorting events manually. 'disable' - Clicking a column header has no effect.

Parameters

string $sort

Return Value

TableChart

Exceptions

InvalidConfigValue

at line 353
TableChart sortAscending( bool $sort)

The order in which the initial sort column is sorted. True for ascending, false for descending. Ignored if sortColumn is not specified.

Parameters

bool $sort

Return Value

TableChart

Exceptions

InvalidConfigValue

at line 367
TableChart sortColumn( int $sort)

An index of a column in the data table, by which the table is initially sorted.

The column will be marked with a small arrow indicating the sort order.

Parameters

int $sort

Return Value

TableChart

Exceptions

InvalidConfigValue

at line 380
TableChart startPage( int $start)

The first table page to display. Used only if page is in mode enable/event.

Parameters

int $start

Return Value

TableChart

Exceptions

InvalidConfigValue