ColumnChart
class ColumnChart extends Chart (View source)
ColumnChart Class
A vertical bar chart that is rendered within the browser using SVG or VML. Displays tips when hovering over bars. For a horizontal version of this chart, see the Bar Chart.
Traits
Constants
TYPE |
Javascript chart type.
|
VERSION |
Javascript chart version.
|
VIZ_PACKAGE |
Javascript chart package.
|
VIZ_CLASS |
Google's visualization class name.
|
Methods
Builds a new ColumnChart with the given label, datatable and options.
Shortcut method to set the value of an option and return $this.
Parses the config array by passing the values through each method to check validity against if the option exists.
Sets any configuration option, with no checks for type / validity
The background color for the main area of the chart.
An object with members to configure the placement and size of the chart area (where the chart itself is drawn, excluding axis and legends).
An object with members to configure various aspects of the legend.
Where to place the chart title, compared to the chart area.
Where to place the axis titles, compared to the chart area.
The width of a group of bars, specified in either of these formats: - Pixels (e.g. 50).
An object with members to configure various horizontal axis elements.
If set to true, stacks the elements for all series at each domain value.
Defines how the chart trendlines will be displayed.
Specifies properties for individual vertical axes
An object with members to configure various vertical axis elements.
Details
at line 91
__construct(
Label $chartLabel,
DataTable $datatable,
array $config = array())
Builds a new ColumnChart with the given label, datatable and options.
in
JsonConfig at line 64
mixed
__get(
string $option)
Get the value of a set option via magic method.
in
JsonConfig at line 75
Options
getOptions()
Gets the Options object for the JsonConfig
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.
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.
in
JsonConfig at line 275
array
jsonSerialize()
Custom serialization of the JsonConfig object.
in
Chart at line 111
string
getType()
Returns the chart type.
in
Chart at line 122
bool
hasEvents()
Checks if any events have been assigned to the chart.
in
Chart at line 133
EventManager
getEvents()
Retrieves the events if any have been assigned to the chart.
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 ]
in
Chart at line 196
Chart
datatable(
DataTable $datatable)
Assigns a datatable to use for the 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.
in
Chart at line 251
string
getDataTableJson()
Returns a JSON string representation of the datatable.
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.
in
Chart at line 290
Chart
animation(
array $animationConfig)
Set the animation options for a 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'
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.
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']
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.
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.
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.
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.
in
Chart at line 461
Chart
titleTextStyle(
TextStyle $textStyle)
An array of options for defining the title text style.
in
Chart at line 474
Chart
tooltip(
array $tooltip)
An object with members to configure various tooltip elements.
in
AxisTitlesPositionTrait at line 21
Chart
axisTitlesPosition(
string $position)
Where to place the axis titles, compared to the chart area.
Supported values: in - Draw the axis titles inside the the chart area. out - Draw the axis titles outside the chart area. none - Omit the axis titles.
in
BarGroupWidthTrait at line 20
Chart
barGroupWidth(
int|string $barGroupWidth)
The width of a group of bars, specified in either of these formats: - Pixels (e.g. 50).
- Percentage of the available width for each group (e.g. '20%'), where '100%' means that groups have no space between them.
in
HorizontalAxisTrait at line 18
Chart
hAxis(
array $horizontalAxisConfig)
An object with members to configure various horizontal axis elements.
To specify properties of this property, create a new HorizontalAxis object, set the values then pass it to this function or to the constructor.
in
IsStackedTrait at line 51
Chart
isStacked(
bool|string $isStacked)
If set to true, stacks the elements for all series at each domain value.
Note: In Column, Area, and SteppedArea charts, Google Charts reverses the order of legend items to better correspond with the stacking of the series elements (E.g. series 0 will be the bottom-most legend item). This does not apply to Bar Charts.
The isStacked option also supports 100% stacking, where the stacks of elements at each domain value are rescaled to add up to 100%.
The options for isStacked are:
false — elements will not stack. This is the default option. true — stacks elements for all series at each domain value. 'percent' — stacks elements for all series at each domain value and rescales them such that they add up to 100%, with each element's value calculated as a percentage of 100%. 'relative' — stacks elements for all series at each domain value and rescales them such that they add up to 1, with each element's value calculated as a fraction of 1. 'absolute' — functions the same as isStacked: true.
For 100% stacking, the calculated value for each element will appear in the tooltip after its actual value.
The target axis will default to tick values based on the relative 0-1 scale as fractions of 1 for 'relative', and 0-100% for 'percent' (Note: when using the 'percent' option, the axis/tick values are displayed as percentages, however the actual values are the relative 0-1 scale values. This is because the percentage axis ticks are the result of applying a format of "#.##%" to the relative 0-1 scale values. When using isStacked: 'percent', be sure to specify any ticks/gridlines using the relative 0-1 scale values). You can customize the gridlines/tick values and formatting using the appropriate hAxis/vAxis options.
100% stacking only supports data values of type number, and must have a baseline of zero.
in
TrendlinesTrait at line 17
Chart
trendlines(
array $trendlineConfigArray)
Defines how the chart trendlines will be displayed.
in
VerticalAxesTrait at line 25
Chart
vAxes(
array $vAxisConfigArray)
Specifies properties for individual vertical axes
If the chart has multiple vertical axes. Each child object is a vAxis object, and can contain all the properties supported by vAxis. These property values override any global settings for the same property.
To specify a chart with multiple vertical axes, first define a new axis using series.targetAxisIndex, then configure the axis using vAxes.
in
VerticalAxisTrait at line 18
Chart
vAxis(
array $verticalAxisConfig)
An object with members to configure various vertical axis elements.
To specify properties of this property, create a new VerticalAxis object, set the values then pass it to this function or to the constructor.