CWIS Developer Documentation
|
Class for generating and displaying a bar chart. More...
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... | |
![]() | |
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" |
![]() | |
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 | |
$BarWidth = NULL | |
![]() | |
$Data = [] | |
$LegendPosition = self::LEGEND_BOTTOM | |
$Colors = NULL | |
$Labels = [] | |
$LegendLabels = [] | |
$Height = 600 | |
$Width = 600 | |
$TooltipLabels = [] | |
$Chart = NULL | |
Additional Inherited Members | |
![]() | |
static | PrepForDisplayingCachedVersion () |
Set up the chart environment so that cached HTML from a previous Display() call will function properly. More... | |
![]() | |
static | RequireNeededFiles () |
Include necessary JS/CSS for chart generation. More... | |
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 = NULL | ) |
Get/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 57 of file BarChart.php.
References $AxisType.
Referenced by BinTimestamp(), and PrepareData().
BarChart::BarWidth | ( | $NewValue = NULL | ) |
Get/set bar width as a percentage of the distance between ticks.
int | null | $NewValue | Updated bar width or NULL to use the C3 default. |
Exception | If an invalid bar width is supplied. |
Definition at line 102 of file BarChart.php.
References $BarWidth.
Referenced by PrepareData().
|
protected |
Determine which bin a specified timestamp belongs in.
mixed | $TS | Input timestamp. |
Definition at line 462 of file BarChart.php.
References AxisType().
Referenced by SortDataIntoBins().
BarChart::Gridlines | ( | $NewValue = NULL | ) |
Enable/disable display of grid lines.
bool | $NewValue | TRUE to show grid lines. |
Exception | If an invalid value is supplied. |
Definition at line 182 of file BarChart.php.
References $Gridlines.
Referenced by PrepareData().
BarChart::Horizontal | ( | $NewValue = NULL | ) |
Get/Set horizontal display setting.
bool | $NewValue | TRUE to generate a horizontal bar chart. |
Exception | If an invalid value is supplied. |
Definition at line 162 of file BarChart.php.
References $Horizontal.
Referenced by PrepareData().
|
protected |
Get the next bin.
int | $BinTS | UNIX timestamp for the left edge of the current bin. |
Definition at line 501 of file BarChart.php.
Referenced by SortDataIntoBins().
|
protected |
Prepare data for plotting.
Definition at line 231 of file BarChart.php.
References Chart_Base\$Data, $YLabel, Chart_Base\AddToChart(), AxisType(), BarWidth(), Gridlines(), Horizontal(), Chart_Base\Labels(), 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 519 of file BarChart.php.
References Chart_Base\LegendLabels().
Referenced by PrepareData().
BarChart::ShowCategoryLabels | ( | $NewValue = NULL | ) |
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. |
Exception | If an invalid value is supplied. |
Definition at line 203 of file BarChart.php.
References $ShowCategoryLabels.
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 384 of file BarChart.php.
References BinTimestamp(), and NextBin().
Referenced by PrepareData().
BarChart::Stacked | ( | $NewValue = NULL | ) |
Get/Set bar stacking setting.
bool | $NewValue | TRUE to generate a stacked chart. |
Exception | If an invalid value is supplied. |
Definition at line 141 of file BarChart.php.
References $Stacked.
Referenced by __construct(), and PrepareData().
BarChart::YLabel | ( | $NewValue = NULL | ) |
Get/set the Y axis label for a bar chart.
string | $NewValue | Label to use. |
Definition at line 86 of file BarChart.php.
References $YLabel.
Referenced by PrepareData().
BarChart::Zoom | ( | $NewValue = NULL | ) |
Enable/Disable zooming for this chart.
string | $NewValue | TRUE to enable zooming. |
Exception | If an invalid value is supplied. |
Definition at line 122 of file BarChart.php.
References $Zoom.
Referenced by PrepareData().
|
protected |
Definition at line 532 of file BarChart.php.
Referenced by AxisType().
|
protected |
Definition at line 540 of file BarChart.php.
Referenced by BarWidth().
|
protected |
Definition at line 538 of file BarChart.php.
Referenced by Gridlines().
|
protected |
Definition at line 536 of file BarChart.php.
Referenced by Horizontal().
|
protected |
Definition at line 539 of file BarChart.php.
Referenced by ShowCategoryLabels().
|
protected |
Definition at line 537 of file BarChart.php.
|
protected |
Definition at line 535 of file BarChart.php.
Referenced by Stacked().
|
protected |
Definition at line 533 of file BarChart.php.
Referenced by PrepareData(), and YLabel().
|
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.