PivotStyles {pivottabler} | R Documentation |
R6 class that defines a collection of styles.
Description
The 'PivotStyles' class is a collection of 'PivotStyle' objects. It defines all of the base styles needed to style/theme a pivot table. It also defines the names of the styles that are used for styling the different parts of the pivot table.
Format
R6Class
object.
Active bindings
count
The number of 'PivotStyle' objects in this 'PivotStyles' collection.
theme
A theme name to represent this collection of styles.
styles
A list containing the 'PivotStyle' objects in this 'PivotStyles' collection.
allowExternalStyles
Default 'FALSE', which means this 'PivotStyles' object checks that style names specified for styling the different parts of the pivot table must exist in the styles collection. If they do not an error will occur. Specify 'TRUE' to disable this check, e.g. if the style definitions are not managed by 'pivottabler' but instead in an external system.
tableStyle
The name of the style for the HTML table element.
rootStyle
The name of the style for the HTML cell at the top left of the pivot table.
rowHeaderStyle
The name of the style for the row headers in the pivot table.
colHeaderStyle
The name of the style for the column headers in the pivot table.
outlineRowHeaderStyle
The name of the style for the outline row headers in the pivot table.
outlineColHeaderStyle
The name of the style for the outline column headers in the pivot table.
cellStyle
The name of the cell style for the non-total cells in the body of the pivot table.
outlineCellStyle
The name of the cell style for the non-total outline cells in the body of the pivot table.
totalStyle
The name of the cell style for the total cells in the pivot table.
Methods
Public methods
Method new()
Create a new 'PivotStyles' object.
Usage
PivotStyles$new(parentPivot, themeName = NULL, allowExternalStyles = FALSE)
Arguments
parentPivot
The pivot table that this 'PivotStyles' instance belongs to.
themeName
A theme name to represent this collection of styles.
allowExternalStyles
Default 'FALSE', which means this 'PivotStyles' object checks that style names specified for styling the different parts of the pivot table must exist in the styles collection. If they do not an error will occur. Specify 'TRUE' to disable this check, e.g. if the style definitions are not managed by 'pivottabler' but instead in an external system.
Returns
A new 'PivotStyles' object.
Method isExistingStyle()
Check whether a style with the specified style name exists in the collection.
Usage
PivotStyles$isExistingStyle(styleName = NULL)
Arguments
styleName
The name of the style.
Returns
'TRUE' if a style with the specified name exists, 'FALSE' otherwise.
Method getStyle()
Retrieve a style with the specified style name.
Usage
PivotStyles$getStyle(styleName = NULL)
Arguments
styleName
The name of the style.
Returns
A 'PivotStyle' object.
Method addStyle()
Add a new style to the collection of styles.
Usage
PivotStyles$addStyle(styleName = NULL, declarations = NULL)
Arguments
styleName
The name of the new style.
declarations
CSS style declarations in the form of a list, e.g. 'list("font-weight"="bold", "color"="#0000FF")'
Returns
The newly created 'PivotStyle' object.
Method copyStyle()
Create a copy of a style with the specified name and store it in the collection.
Usage
PivotStyles$copyStyle(styleName = NULL, newStyleName = NULL)
Arguments
styleName
The name of the style to copy.
newStyleName
The name for the new style.
Returns
The newly created 'PivotStyle' object.
Method asCSSRule()
Get a style definition in the form of a CSS rule.
Usage
PivotStyles$asCSSRule(styleName = NULL, selector = NULL)
Arguments
styleName
The name of the style.
selector
A CSS selector, used to select the element(s) to be styled.
Returns
The style declarations in the form of a CSS rule, i.e. selector property-name1: property-value1, property-name2: property-value2, ... e.g. div font-weight: bold, color: #0000FF
Method asNamedCSSStyle()
Get a style definition in the form of a named CSS style.
Usage
PivotStyles$asNamedCSSStyle(styleName = NULL, styleNamePrefix = NULL)
Arguments
styleName
The name of the style.
styleNamePrefix
A prefix to prepend to the style name.
Returns
The style declarations in the form of named CSS style, i.e. .prefix-stylename property-name1: property-value1, property-name2: property-value2, ... e.g. .pvt1Cell font-weight: bold, color: #0000FF
Method asList()
Return the contents of this object as a list for debugging.
Usage
PivotStyles$asList()
Returns
A list of various object properties.
Method asJSON()
Return the contents of this object as JSON for debugging.
Usage
PivotStyles$asJSON()
Returns
A JSON representation of various object properties.
Method asString()
Return a representation of this object as a character value.
Usage
PivotStyles$asString(seperator = ", ")
Arguments
seperator
A character value to use when concatenating multiple styles.
Returns
A character summary of various object properties.
Method clone()
The objects of this class are cloneable with this method.
Usage
PivotStyles$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
Examples
pt <- PivotTable$new()
# ...
pivotStyles <- PivotStyles$new(pt, themeName="compact")
pivotStyles$addStyle(styleName="MyNewStyle", list(
font="0.75em arial",
padding="2px",
border="1px solid lightgray",
"vertical-align"="middle",
"text-align"="center",
"font-weight"="bold",
"background-color"="#F2F2F2"
))