|
23 | 23 | defaultSlopeGraphMode = 'item', |
24 | 24 | ignoreUnsupportedBrowser = FALSE |
25 | 25 | ) |
26 | | - |
27 | | -.lineupImpl = function(data, |
28 | | - width, |
29 | | - height, |
30 | | - elementId, |
31 | | - options, |
32 | | - ranking, |
33 | | - dependencies, |
34 | | - lineupType, |
| 26 | +#' taggle - factory for Taggle HTMLWidget |
| 27 | +#' |
| 28 | +#' @param data data frame like object i.e. also crosstalk shared data frame |
| 29 | +#' @param options LineUp options |
| 30 | +#' \describe{ |
| 31 | +#' \item{filterGlobally}{whether filter within one ranking applies to all rankings (default: TRUE)} |
| 32 | +#' \item{singleSelection}{restrict to single item selection (default: FALSE} |
| 33 | +#' \item{noCriteriaLimits}{allow more than one sort and grouping criteria (default: FALSE)} |
| 34 | +#' \item{animated}{use animated transitions (default: TRUE)} |
| 35 | +#' \item{sidePanel}{show side panel (TRUE, FALSE, 'collapsed') (default: 'collapsed')} |
| 36 | +#' \item{hierarchyIndicator}{show sorting and grouping hierarchy indicator (TRUE, FALSE) (default: TRUE)} |
| 37 | +#' \item{labelRotation}{how many degrees should a label be rotated in case of narrow columns (default: 0)} |
| 38 | +#' \item{summaryHeader}{show summary histograms in the header (default: TRUE)} |
| 39 | +#' \item{overviewMode}{show overview mode in Taggle by default (default: FALSE)} |
| 40 | +#' \item{expandLineOnHover}{expand to full row height on mouse over (default: FALSE)} |
| 41 | +#' \item{defaultSlopeGraphMode}{default slope graph mode: item,band (default: 'item')} |
| 42 | +#' \item{ignoreUnsupportedBrowser}{ignore unsupported browser detection at own risk (default: FALSE)} |
| 43 | +#' \item{rowHeight}{height of a row in pixel (default: 18)} |
| 44 | +#' \item{rowPadding}{padding between two rows in pixel (default: 2)} |
| 45 | +#' \item{groupHeight}{height of an aggregated group in pixel (default: 40)} |
| 46 | +#' \item{groupPadding}{padding between two groups in pixel (default: 5)} |
| 47 | +#' } |
| 48 | +#' @param ranking ranking definition created using \code{\link{lineupRanking}} |
| 49 | +#' @param ... additional ranking definitions like 'ranking1=...' due to restrictions in converting parameters |
| 50 | +#' |
| 51 | +#' @return lineup builder objects |
| 52 | +#' |
| 53 | +#' @examples |
| 54 | +#' \dontrun{ |
| 55 | +#' taggle(mtcars) |
| 56 | +#' taggle(iris) |
| 57 | +#' } |
| 58 | +#' |
| 59 | +#' @export |
| 60 | +lineupBuilder = function(data, |
| 61 | + options = c(.lineupDefaultOptions), |
| 62 | + ranking = NULL, |
35 | 63 | ...) { |
36 | 64 | # extend with all the default options |
37 | 65 | options = c(options, .lineupDefaultOptions[!(names(.lineupDefaultOptions) %in% names(options))]) |
|
73 | 101 | cols[['rowname']] = list(type = 'string', column = 'rowname', frozen = TRUE) |
74 | 102 |
|
75 | 103 | # forward options using x |
76 | | - x = list( |
| 104 | + structure(list( |
77 | 105 | data = cbind(rowname = rownames(data), data), |
78 | 106 | colnames = c('rowname', colnames(data)), |
79 | 107 | cols = cols, |
80 | 108 | crosstalk = list(key = key, group = group), |
81 | 109 | options = options, |
82 | 110 | rankings = list(ranking = ranking, ...) |
83 | | - ) |
| 111 | + ), class='LineUpBuilder') |
| 112 | +} |
| 113 | + |
| 114 | +.buildLineUpWidget = function(x, width, height, elementId, dependencies, lineupType) { |
84 | 115 | # create widget |
85 | 116 | htmlwidgets::createWidget( |
86 | 117 | name = lineupType, |
|
93 | 124 | ) |
94 | 125 | } |
95 | 126 |
|
| 127 | +#' lineup - factory for LineUp HTMLWidget |
| 128 | +#' |
| 129 | +#' @param x LineUpBuilder object |
| 130 | +#' @param width width of the element |
| 131 | +#' @param height height of the element |
| 132 | +#' @param elementId unique element id |
| 133 | +#' @param dependencies include crosstalk dependencies |
| 134 | +#' |
| 135 | +#' @return html lineup widget |
| 136 | +#' |
| 137 | +#' @export |
| 138 | +buildLineUp = function(x, width = '100%', |
| 139 | + height = NULL, |
| 140 | + elementId = NULL, |
| 141 | + dependencies = crosstalk::crosstalkLibs()) { |
| 142 | + .buildLineUpWidget(x, width, height, elementId, dependencies, lineupType='lineup') |
| 143 | +} |
| 144 | + |
| 145 | +#' taggle - factory for Taggle HTMLWidget |
| 146 | +#' |
| 147 | +#' @param x LineUpBuilder object |
| 148 | +#' @param width width of the element |
| 149 | +#' @param height height of the element |
| 150 | +#' @param elementId unique element id |
| 151 | +#' @param dependencies include crosstalk dependencies |
| 152 | +#' |
| 153 | +#' @return html taggle widget |
| 154 | + |
| 155 | +#' @export |
| 156 | +buildTaggle = function(x, width = '100%', |
| 157 | + height = NULL, |
| 158 | + elementId = NULL, |
| 159 | + dependencies = crosstalk::crosstalkLibs()) { |
| 160 | + .buildLineUpWidget(x, width, height, elementId, dependencies, lineupType='taggle') |
| 161 | +} |
| 162 | + |
| 163 | + |
96 | 164 | #' lineup - factory for LineUp HTMLWidget |
97 | 165 | #' |
98 | 166 | #' @param data data frame like object i.e. also crosstalk shared data frame |
@@ -139,7 +207,8 @@ lineup = function(data, |
139 | 207 | ranking = NULL, |
140 | 208 | dependencies = crosstalk::crosstalkLibs(), |
141 | 209 | ...) { |
142 | | - .lineupImpl(data, width, height, elementId, options, ranking, dependencies, lineupType='lineup', ...) |
| 210 | + x = lineupBuilder(data, options, ranking, ...) |
| 211 | + buildLineUp(x, width, height, elementId, dependencies) |
143 | 212 | } |
144 | 213 |
|
145 | 214 |
|
@@ -189,7 +258,8 @@ taggle = function(data, |
189 | 258 | ranking = NULL, |
190 | 259 | dependencies = crosstalk::crosstalkLibs(), |
191 | 260 | ...) { |
192 | | - .lineupImpl(data, width, height, elementId, options, ranking, dependencies, lineupType='taggle', ...) |
| 261 | + x = lineupBuilder(data, options, ranking, ...) |
| 262 | + buildTaggle(x, width, height, elementId, dependencies) |
193 | 263 | } |
194 | 264 |
|
195 | 265 | #' helper function for creating a LineUp ranking definition as used by \code{\link{lineup}} |
|
0 commit comments