class GeoChart extends Chart (View source)

GeoChart Class

A Geochart is a map of a country, a continent, or a region with two modes: - The region mode colorizes whole regions, such as countries, provinces, or states. - The marker mode marks designated regions using bubbles that are scaled according to a value that you specify.

Traits

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 GeoChart 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
colorAxis( array $colorAxisConfig)

An object that specifies a mapping between color column values and colors or a gradient scale.

datalessRegionColor( string $drc)

Color to assign to regions with no associated data.

displayMode( string $displayMode)

Which type of map this is.

enableRegionInteractivity( bool $eri)

If true, enable region interactivity, including focus and tool-tip elaboration on mouse hover, and region selection and firing of regionClick and select events on mouse click.

keepAspectRatio( bool $kar)

If true, the map will be drawn at the largest size that can fit inside the chart area at its natural aspect ratio.

region( string $region)

The area to display on the map. (Surrounding areas will be displayed as well.) Can be one of the following:

magnifyingGlass( array $magnifyingGlassConfig)

Sets up the magnifying glass, so when the user lingers over a cluttered marker, a magnifiying glass will be opened.

markerOpacity( float $markerOpacity)

The opacity of the markers, where 0.0 is fully transparent and 1.0 is fully opaque.

resolution( string $resolution)

The resolution of the map borders. Choose one of the following values:

sizeAxis( array $sizeAxisConfig)

An object with members to configure how values are associated with bubble sizes.

Details

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

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

Parameters

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

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

in ColorAxisTrait at line 16
Chart colorAxis( array $colorAxisConfig)

An object that specifies a mapping between color column values and colors or a gradient scale.

Parameters

array $colorAxisConfig

Return Value

Chart

at line 106
GeoChart datalessRegionColor( string $drc)

Color to assign to regions with no associated data.

Parameters

string $drc

Return Value

GeoChart

Exceptions

InvalidConfigValue

at line 126
GeoChart displayMode( string $displayMode)

Which type of map this is.

The DataTable format must match the value specified.

The following values are supported: 'auto' - Choose based on the format of the DataTable. 'regions' - This is a region map 'markers' - This is a marker map

Parameters

string $displayMode

Return Value

GeoChart

Exceptions

InvalidConfigValue

at line 149
GeoChart enableRegionInteractivity( bool $eri)

If true, enable region interactivity, including focus and tool-tip elaboration on mouse hover, and region selection and firing of regionClick and select events on mouse click.

The default is true in region mode, and false in marker mode.

Parameters

bool $eri

Return Value

GeoChart

Exceptions

InvalidConfigValue

at line 170
GeoChart keepAspectRatio( bool $kar)

If true, the map will be drawn at the largest size that can fit inside the chart area at its natural aspect ratio.

If only one of the width and height options is specified, the other one will be calculated according to the aspect ratio.

If false, the map will be stretched to the exact size of the chart as specified by the width and height options.

Parameters

bool $kar

Return Value

GeoChart

Exceptions

InvalidConfigValue

at line 193
GeoChart region( string $region)

The area to display on the map. (Surrounding areas will be displayed as well.) Can be one of the following:

'world' - A map of the entire world.

A continent or a sub-continent, specified by its 3-digit code, e.g., '011' for Western Africa.

A country, specified by its ISO 3166-1 alpha-2 code, e.g., 'AU' for Australia.

A state in the United States, specified by its ISO 3166-2:US code, e.g., 'US-AL' for Alabama. Note that the resolution option must be set to either 'provinces' or 'metros'.

Parameters

string $region

Return Value

GeoChart

Exceptions

InvalidConfigValue

at line 206
GeoChart magnifyingGlass( array $magnifyingGlassConfig)

Sets up the magnifying glass, so when the user lingers over a cluttered marker, a magnifiying glass will be opened.

Parameters

array $magnifyingGlassConfig

Return Value

GeoChart

Exceptions

InvalidConfigValue

at line 219
GeoChart markerOpacity( float $markerOpacity)

The opacity of the markers, where 0.0 is fully transparent and 1.0 is fully opaque.

Parameters

float $markerOpacity

Return Value

GeoChart

Exceptions

InvalidConfigValue

at line 245
GeoChart resolution( string $resolution)

The resolution of the map borders. Choose one of the following values:

'countries' - Supported for all regions, except for US state regions. 'provinces' - Supported only for country regions and US state regions. Not supported for all countries; please test a country to see whether this option is supported. 'metros' - Supported for the US country region and US state regions only.

Parameters

string $resolution

Return Value

GeoChart

Exceptions

InvalidConfigValue

at line 263
GeoChart sizeAxis( array $sizeAxisConfig)

An object with members to configure how values are associated with bubble sizes.

Parameters

array $sizeAxisConfig

Return Value

GeoChart

Exceptions

InvalidConfigValue