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=NULL)
 Get/set the axis type of a bar chart (default is AXIS_CATEGORY). More...
 
 YLabel ($NewValue=NULL)
 Get/set the Y axis label for a bar chart. More...
 
 BarWidth ($NewValue=NULL)
 Get/set bar width as a percentage of the distance between ticks. More...
 
 Zoom ($NewValue=NULL)
 Enable/Disable zooming for this chart. More...
 
 Stacked ($NewValue=NULL)
 Get/Set bar stacking setting. More...
 
 Horizontal ($NewValue=NULL)
 Get/Set horizontal display setting. More...
 
 Gridlines ($NewValue=NULL)
 Enable/disable display of grid lines. More...
 
 ShowCategoryLabels ($NewValue=NULL)
 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...
 
 Labels ($NewValue=NULL)
 Get/set chart element labels (pie slices, bars, etc). More...
 
 Colors ($NewValue=NULL)
 Get/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
 
 $BarWidth = NULL
 
- Protected Attributes inherited from Chart_Base
 $Data = []
 
 $LegendPosition = self::LEGEND_BOTTOM
 
 $Colors = NULL
 
 $Labels = []
 
 $LegendLabels = []
 
 $Height = 600
 
 $Width = 600
 
 $TooltipLabels = []
 
 $Chart = NULL
 

Additional Inherited Members

- Static Public Member Functions inherited from Chart_Base
static PrepForDisplayingCachedVersion ()
 Set up the chart environment so that cached HTML from a previous Display() call will function properly. More...
 
- Static Protected Member Functions inherited from Chart_Base
static RequireNeededFiles ()
 Include necessary JS/CSS for chart generation. More...
 

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 = NULL)

Get/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.
Returns
mixed Current AxisType.
Exceptions
ExceptionIf an invalid axis type is supplied.

Definition at line 57 of file BarChart.php.

References $AxisType.

Referenced by BinTimestamp(), and PrepareData().

Here is the caller graph for this function:

BarChart::BarWidth (   $NewValue = NULL)

Get/set bar width as a percentage of the distance between ticks.

Parameters
int | null$NewValueUpdated bar width or NULL to use the C3 default.
Returns
mixed Current Barwidth setting.
Exceptions
ExceptionIf an invalid bar width is supplied.

Definition at line 102 of file BarChart.php.

References $BarWidth.

Referenced by 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 462 of file BarChart.php.

References AxisType().

Referenced by SortDataIntoBins().

Here is the caller graph for this function:

BarChart::Gridlines (   $NewValue = NULL)

Enable/disable display of grid lines.

Parameters
bool$NewValueTRUE to show grid lines.
Returns
bool Current grid line sitting.
Exceptions
ExceptionIf an invalid value is supplied.

Definition at line 182 of file BarChart.php.

References $Gridlines.

Referenced by PrepareData().

Here is the caller graph for this function:

BarChart::Horizontal (   $NewValue = NULL)

Get/Set horizontal display setting.

Parameters
bool$NewValueTRUE to generate a horizontal bar chart.
Returns
bool Current horizontal setting.
Exceptions
ExceptionIf an invalid value is supplied.

Definition at line 162 of file BarChart.php.

References $Horizontal.

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 501 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 519 of file BarChart.php.

References Chart_Base\LegendLabels().

Referenced by PrepareData().

Here is the caller graph for this function:

BarChart::ShowCategoryLabels (   $NewValue = NULL)

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.
Returns
bool Current category labels setting.
Exceptions
ExceptionIf an invalid value is supplied.

Definition at line 203 of file BarChart.php.

References $ShowCategoryLabels.

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 384 of file BarChart.php.

References BinTimestamp(), and NextBin().

Referenced by PrepareData().

Here is the caller graph for this function:

BarChart::Stacked (   $NewValue = NULL)

Get/Set bar stacking setting.

Parameters
bool$NewValueTRUE to generate a stacked chart.
Returns
bool Current stacking setting.
Exceptions
ExceptionIf an invalid value is supplied.

Definition at line 141 of file BarChart.php.

References $Stacked.

Referenced by __construct(), and PrepareData().

Here is the caller graph for this function:

BarChart::YLabel (   $NewValue = NULL)

Get/set the Y axis label for a bar chart.

Parameters
string$NewValueLabel to use.
Returns
string Current YLabel.

Definition at line 86 of file BarChart.php.

References $YLabel.

Referenced by PrepareData().

Here is the caller graph for this function:

BarChart::Zoom (   $NewValue = NULL)

Enable/Disable zooming for this chart.

Parameters
string$NewValueTRUE to enable zooming.
Returns
bool Current Zoom setting.
Exceptions
ExceptionIf an invalid value is supplied.

Definition at line 122 of file BarChart.php.

References $Zoom.

Referenced by PrepareData().

Here is the caller graph for this function:

Member Data Documentation

BarChart::$AxisType = self::AXIS_CATEGORY
protected

Definition at line 532 of file BarChart.php.

Referenced by AxisType().

BarChart::$BarWidth = NULL
protected

Definition at line 540 of file BarChart.php.

Referenced by BarWidth().

BarChart::$Gridlines = TRUE
protected

Definition at line 538 of file BarChart.php.

Referenced by Gridlines().

BarChart::$Horizontal = FALSE
protected

Definition at line 536 of file BarChart.php.

Referenced by Horizontal().

BarChart::$ShowCategoryLabels = TRUE
protected

Definition at line 539 of file BarChart.php.

Referenced by ShowCategoryLabels().

BarChart::$SingleCategory = FALSE
protected

Definition at line 537 of file BarChart.php.

BarChart::$Stacked = FALSE
protected

Definition at line 535 of file BarChart.php.

Referenced by Stacked().

BarChart::$YLabel = NULL
protected

Definition at line 533 of file BarChart.php.

Referenced by PrepareData(), and YLabel().

BarChart::$Zoom = FALSE
protected

Definition at line 534 of file BarChart.php.

Referenced by Zoom().

const BarChart::AXIS_CATEGORY = "category"

Definition at line 219 of file BarChart.php.

const BarChart::AXIS_TIME_DAILY = "daily"

Definition at line 220 of file BarChart.php.

const BarChart::AXIS_TIME_MONTHLY = "monthly"

Definition at line 222 of file BarChart.php.

const BarChart::AXIS_TIME_WEEKLY = "weekly"

Definition at line 221 of file BarChart.php.

const BarChart::AXIS_TIME_YEARLY = "yearly"

Definition at line 223 of file BarChart.php.


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