CWIS Developer Documentation
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
BarChart Class Reference

Class for generating and displaying a bar chart. More...

Inheritance diagram for BarChart:
Inheritance graph
[legend]
Collaboration diagram for BarChart:
Collaboration graph
[legend]

Public Member Functions

 __construct ($Data)
 Class constructor. More...
 
 AxisType ($NewValue)
 Set the axis type of a bar chart (default is AXIS_CATEGORY). More...
 
 YLabel ($NewValue)
 Set the Y axis label for a bar chart. More...
 
 Zoom ($NewValue)
 Enable/Disable zooming for this chart. More...
 
 Stacked ($NewValue)
 Enable/Disable bar stacking. More...
 
 Horizontal ($NewValue)
 Enable/disable horizontal display. More...
 
 Gridlines ($NewValue)
 Enable/disable display of grid lines. More...
 
 ShowCategoryLabels ($NewValue)
 Enable/disable display of category labels along the X axis on categorical charts (by default, they are shown). More...
 
- Public Member Functions inherited from Chart_Base
 LegendPosition ($Position)
 Set legend position. More...
 
 LegendLabels ($LegendLabels)
 Set shortened labels to be used in the legend of the chart. More...
 
 Colors ($NewValue=NULL)
 Set color palette. More...
 
 Height ($NewValue)
 Get/Set height of the chart including the legend. More...
 
 Width ($NewValue)
 Get/Set width of the chart including the legend. More...
 
 Display ($ContainerId)
 Display a chart. More...
 

Public Attributes

const AXIS_CATEGORY = "category"
 
const AXIS_TIME_DAILY = "daily"
 
const AXIS_TIME_WEEKLY = "weekly"
 
const AXIS_TIME_MONTHLY = "monthly"
 
const AXIS_TIME_YEARLY = "yearly"
 
- Public Attributes inherited from Chart_Base
const LEGEND_BOTTOM = "bottom"
 
const LEGEND_RIGHT = "right"
 
const LEGEND_INSET = "inset"
 
const LEGEND_NONE = "none"
 

Protected Member Functions

 PrepareData ()
 Prepare data for plotting. More...
 
 SortDataIntoBins ($BarNames)
 Sort the user-provided data into bins with sizes given by $this->AxisType, filling in any gaps in the data given by the user. More...
 
 BinTimestamp ($TS)
 Determine which bin a specified timestamp belongs in. More...
 
 NextBin ($BinTS)
 Get the next bin. More...
 
 ShortCategoryNames ($LongNames)
 Get abbreviated category names (e.g., for the legend). More...
 
- Protected Member Functions inherited from Chart_Base
 PrepareData ()
 Massage data provided by the user into an appropriate format for plotting and do any necessary tweaks to $this->Chart. More...
 
 DeclareStateVariables ()
 Output var declarations for any js state variables needed in this chart's display helper functions. More...
 
 DeclareHelperFunctions ()
 Output function definitions for any needed javascript display helper functions. More...
 
 GenerateRgbColorString ($DataIndex)
 Get RGB hex color when no color supplied. More...
 
 AddToChart ($Data)
 Merge an array of settings into $this->Chart. More...
 
 AddToArray (&$Tgt, $Data)
 Merge elements from a source array into a dest array. More...
 

Protected Attributes

 $AxisType = self::AXIS_CATEGORY
 
 $YLabel = NULL
 
 $Zoom = FALSE
 
 $Stacked = FALSE
 
 $Horizontal = FALSE
 
 $SingleCategory = FALSE
 
 $Gridlines = TRUE
 
 $ShowCategoryLabels = TRUE
 
- Protected Attributes inherited from Chart_Base
 $Data = []
 
 $LegendPosition = self::LEGEND_BOTTOM
 
 $Colors = NULL
 
 $LegendLabels = []
 
 $Height = 600
 
 $Width = 600
 
 $LabelLUT = []
 
 $Chart = NULL
 

Detailed Description

Class for generating and displaying a bar chart.

Definition at line 13 of file BarChart.php.

Constructor & Destructor Documentation

BarChart::__construct (   $Data)

Class constructor.

Parameters
array$DataData for chart. Keys are X values for each bar (either a category name, a unix timestamp, or any format that strtotime can parse). Values are ints for charts with only one set of bars or associative arrays where the keys give bar names and the values give bar heights for charts with multiple bars.

Definition at line 26 of file BarChart.php.

References Chart_Base\$Data, Chart_Base\LegendPosition(), and Stacked().

Member Function Documentation

BarChart::AxisType (   $NewValue)

Set the axis type of a bar chart (default is AXIS_CATEGORY).

Parameters
string$NewValueAxis type as a BarChart::AXIS_ constant. Allowed values are AXIS_CATEGORY for categorical charts or one of AXIS_TIME_{DAILY,WEEKLY,MONTHLY,YEARLY} for time series plotting.
Exceptions
ExceptionIf an invalid axis type is supplied.

Definition at line 56 of file BarChart.php.

Referenced by BinTimestamp(), and PrepareData().

Here is the caller graph for this function:

BarChart::BinTimestamp (   $TS)
protected

Determine which bin a specified timestamp belongs in.

Parameters
mixed$TSInput timestamp.
Returns
int UNIX timestamp for the left edge of the bin.

Definition at line 362 of file BarChart.php.

References AxisType().

Referenced by SortDataIntoBins().

Here is the caller graph for this function:

BarChart::Gridlines (   $NewValue)

Enable/disable display of grid lines.

Parameters
bool$NewValueTRUE to show grid lines.

Definition at line 116 of file BarChart.php.

Referenced by PrepareData().

Here is the caller graph for this function:

BarChart::Horizontal (   $NewValue)

Enable/disable horizontal display.

Parameters
bool$NewValueTRUE to generate a horizontal bar chart.

Definition at line 107 of file BarChart.php.

Referenced by PrepareData().

Here is the caller graph for this function:

BarChart::NextBin (   $BinTS)
protected

Get the next bin.

Parameters
int$BinTSUNIX timestamp for the left edge of the current bin.
Returns
int UNIX timestamp for the left edge of the next bin.

Definition at line 401 of file BarChart.php.

Referenced by SortDataIntoBins().

Here is the caller graph for this function:

BarChart::PrepareData ( )
protected
BarChart::ShortCategoryNames (   $LongNames)
protected

Get abbreviated category names (e.g., for the legend).

Parameters
array$LongNamesArray of data keyed by long category names.
Returns
array of possibly abbreviated category names.

Definition at line 419 of file BarChart.php.

References Chart_Base\LegendLabels().

Referenced by PrepareData().

Here is the caller graph for this function:

BarChart::ShowCategoryLabels (   $NewValue)

Enable/disable display of category labels along the X axis on categorical charts (by default, they are shown).

Parameters
bool$NewValueTRUE to show category labels.

Definition at line 126 of file BarChart.php.

Referenced by PrepareData().

Here is the caller graph for this function:

BarChart::SortDataIntoBins (   $BarNames)
protected

Sort the user-provided data into bins with sizes given by $this->AxisType, filling in any gaps in the data given by the user.

Parameters
array$BarNamesBars that all bins should have.
Returns
Array of binned data.

Definition at line 284 of file BarChart.php.

References BinTimestamp(), and NextBin().

Referenced by PrepareData().

Here is the caller graph for this function:

BarChart::Stacked (   $NewValue)

Enable/Disable bar stacking.

Parameters
bool$NewValueTRUE to generate a stacked chart.

Definition at line 98 of file BarChart.php.

Referenced by __construct(), and PrepareData().

Here is the caller graph for this function:

BarChart::YLabel (   $NewValue)

Set the Y axis label for a bar chart.

Parameters
string$NewValueLabel to use.

Definition at line 80 of file BarChart.php.

Referenced by PrepareData().

Here is the caller graph for this function:

BarChart::Zoom (   $NewValue)

Enable/Disable zooming for this chart.

Parameters
string$NewValueTRUE to enable zooming.

Definition at line 89 of file BarChart.php.

Referenced by PrepareData().

Here is the caller graph for this function:

Member Data Documentation

BarChart::$AxisType = self::AXIS_CATEGORY
protected

Definition at line 432 of file BarChart.php.

BarChart::$Gridlines = TRUE
protected

Definition at line 438 of file BarChart.php.

BarChart::$Horizontal = FALSE
protected

Definition at line 436 of file BarChart.php.

BarChart::$ShowCategoryLabels = TRUE
protected

Definition at line 439 of file BarChart.php.

BarChart::$SingleCategory = FALSE
protected

Definition at line 437 of file BarChart.php.

BarChart::$Stacked = FALSE
protected

Definition at line 435 of file BarChart.php.

BarChart::$YLabel = NULL
protected

Definition at line 433 of file BarChart.php.

Referenced by PrepareData().

BarChart::$Zoom = FALSE
protected

Definition at line 434 of file BarChart.php.

const BarChart::AXIS_CATEGORY = "category"

Definition at line 132 of file BarChart.php.

const BarChart::AXIS_TIME_DAILY = "daily"

Definition at line 133 of file BarChart.php.

const BarChart::AXIS_TIME_MONTHLY = "monthly"

Definition at line 135 of file BarChart.php.

const BarChart::AXIS_TIME_WEEKLY = "weekly"

Definition at line 134 of file BarChart.php.

const BarChart::AXIS_TIME_YEARLY = "yearly"

Definition at line 136 of file BarChart.php.


The documentation for this class was generated from the following file: