CWIS Developer Documentation
|
Class for generating and displaying a bar chart. More...
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... | |
![]() | |
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" |
![]() | |
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... | |
![]() | |
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 | |
![]() | |
$Data = [] | |
$LegendPosition = self::LEGEND_BOTTOM | |
$Colors = NULL | |
$LegendLabels = [] | |
$Height = 600 | |
$Width = 600 | |
$LabelLUT = [] | |
$Chart = NULL | |
Class for generating and displaying a bar chart.
Definition at line 13 of file BarChart.php.
BarChart::__construct | ( | $Data | ) |
Class constructor.
array | $Data | Data 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().
BarChart::AxisType | ( | $NewValue | ) |
Set the axis type of a bar chart (default is AXIS_CATEGORY).
string | $NewValue | Axis 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. |
Exception | If an invalid axis type is supplied. |
Definition at line 56 of file BarChart.php.
Referenced by BinTimestamp(), and PrepareData().
|
protected |
Determine which bin a specified timestamp belongs in.
mixed | $TS | Input timestamp. |
Definition at line 362 of file BarChart.php.
References AxisType().
Referenced by SortDataIntoBins().
BarChart::Gridlines | ( | $NewValue | ) |
Enable/disable display of grid lines.
bool | $NewValue | TRUE to show grid lines. |
Definition at line 116 of file BarChart.php.
Referenced by PrepareData().
BarChart::Horizontal | ( | $NewValue | ) |
Enable/disable horizontal display.
bool | $NewValue | TRUE to generate a horizontal bar chart. |
Definition at line 107 of file BarChart.php.
Referenced by PrepareData().
|
protected |
Get the next bin.
int | $BinTS | UNIX timestamp for the left edge of the current bin. |
Definition at line 401 of file BarChart.php.
Referenced by SortDataIntoBins().
|
protected |
Prepare data for plotting.
Definition at line 144 of file BarChart.php.
References Chart_Base\$Data, $YLabel, Chart_Base\AddToChart(), AxisType(), Gridlines(), Horizontal(), Chart_Base\LegendLabels(), ShortCategoryNames(), ShowCategoryLabels(), SortDataIntoBins(), Stacked(), YLabel(), and Zoom().
|
protected |
Get abbreviated category names (e.g., for the legend).
array | $LongNames | Array of data keyed by long category names. |
Definition at line 419 of file BarChart.php.
References Chart_Base\LegendLabels().
Referenced by PrepareData().
BarChart::ShowCategoryLabels | ( | $NewValue | ) |
Enable/disable display of category labels along the X axis on categorical charts (by default, they are shown).
bool | $NewValue | TRUE to show category labels. |
Definition at line 126 of file BarChart.php.
Referenced by PrepareData().
|
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.
array | $BarNames | Bars that all bins should have. |
Definition at line 284 of file BarChart.php.
References BinTimestamp(), and NextBin().
Referenced by PrepareData().
BarChart::Stacked | ( | $NewValue | ) |
Enable/Disable bar stacking.
bool | $NewValue | TRUE to generate a stacked chart. |
Definition at line 98 of file BarChart.php.
Referenced by __construct(), and PrepareData().
BarChart::YLabel | ( | $NewValue | ) |
Set the Y axis label for a bar chart.
string | $NewValue | Label to use. |
Definition at line 80 of file BarChart.php.
Referenced by PrepareData().
BarChart::Zoom | ( | $NewValue | ) |
Enable/Disable zooming for this chart.
string | $NewValue | TRUE to enable zooming. |
Definition at line 89 of file BarChart.php.
Referenced by PrepareData().
|
protected |
Definition at line 432 of file BarChart.php.
|
protected |
Definition at line 438 of file BarChart.php.
|
protected |
Definition at line 436 of file BarChart.php.
|
protected |
Definition at line 439 of file BarChart.php.
|
protected |
Definition at line 437 of file BarChart.php.
|
protected |
Definition at line 435 of file BarChart.php.
|
protected |
Definition at line 433 of file BarChart.php.
Referenced by PrepareData().
|
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.