Historytable API Documentation
SoPHIELabs Historytable API Class
The Historytable API provides a simplified functionality to execute render a table of variables.
The core parameters are the column definition and the options. The column definition can be a basic list of variable names or a detailed definition of variable names and context.
Details Column Definition Fields:
name: variable name
- context: EE/ES/ESL/GE/GS/GSL/PE/PS/PSL
- headerContent: Header content
- headerClass: CSS class to add to the header cell
- headerStyle: CSS style to add to the header cell
- valueLabelMap: associative array to print a label instead of the value e.g. array('value1' => 'Value 1', 'value2' => 'Value 2')
- align: left, center, right
- values: manually pass in an array of values
- type: auto, text, html, int, float defaults to auto.
- emptyCellContent: default to "-"
- numberFormatDecimals: number of decimal points to show, defaults to 2
- numberFormatDecimalPoint: decimal point character, defaults to locale setting
- numberFormatThousandsSeparator: thousands separator character, defaults to locale setting
Options:
- defaultContext: EE/ES/ESL/GE/GS/GSL/PE/PS/PSL
- groupLabel: By default the current Group Label is used. This can be overwritten with the option
- participantLabel: By default the current Participant Label is used. This can be overwritten with the option
- stepgroupLabel: By default the current Stepgroup Label is used. This can be overwritten with the option
- stepgroupLoop: By default the current Stepgroup Loop is used. This can be overwritten with the option
- order: asc/desc order of loops with default asc
- noTableTag: boolean to activate or deactivate rendering the table tag, defaults to true
- tableClass: configure the css classes for the table
- tableStyle: add additional ss to table
- tableCaption: add a table header caption element.
- noHeaderRow: boolean to activate or deactivate rendering the header row, defaults to true
- roundsColumnActive: boolean to activate or deactivate rendering the round counter column, defaults to true
- roundsColumnHeaderContent: header content for round column, defaults to "Rounds"
- defaultEmptyCellContent: default to "-"
Example uses:
Simple Column List with Variable Names rendered for the default context of the participant
$api->get('sophielabs_historytable')->renderParticipantTable(array('inputA', 'inputB'));
Extended example
$historytableApi = $api->get('sophielabs_historytable');
$cols = array(
array('context' => 'PSL', 'name' => 'production', 'headerContent' => 'Your Production'),
array('context' => 'EE', 'name' => 'unitCost', 'headerContent' => 'Costs per Unit'),
array('context' => 'GSL', 'name' => 'unitPrice', 'headerContent' => 'Market Price per Unit'),
array('context' => 'PSL', 'name' => 'profit', 'headerContent' => 'Your Profit'),
);
$options = array(
'stepgroupLabel' => 'main',
'stepgroupLoop' => $variableApi->getEE('numberOfRounds')
);
echo $historytableApi->renderParticipantTable($cols, $options);
Init: $historytableApi = $api->get('sophielabs_historytable');
Method: $historytableApi->renderContentRows(...)
Renders the rows of a historytable
Parameters:
- Array $columns Array with column definitions
- Array $options Array with options
Returns String
Method: $historytableApi->renderTable(...)
Renders a historytable
Parameters:
- Array $columns Array with column definitions
- Array $options Array with options
Returns String
Method: $historytableApi->renderParticipantTable(...)
Renders a historytable with the default context of the current participant
Parameters:
- Array $columns Array with column definitions
- Array $options Array with options
Returns String
Method: $historytableApi->renderGroupTable(...)
Renders a historytable with the default context of the current group
Parameters:
- Array $columns Array with column definitions
- Array $options Array with options
Returns String