|
| 1 | +#' <Add Title> |
| 2 | +#' |
| 3 | +#' <Add Description> |
| 4 | +#' |
| 5 | +#' @import htmlwidgets |
| 6 | +#' |
| 7 | +#' @export |
| 8 | +flowmapblue <- function( |
| 9 | + locations, flows, |
| 10 | + mapboxAccessToken = NULL, |
| 11 | + clustering = TRUE, |
| 12 | + animation = FALSE, |
| 13 | + darkMode = FALSE |
| 14 | +) { |
| 15 | + |
| 16 | + # pass the data and settings using 'x' |
| 17 | + x <- list( |
| 18 | + locations = locations, |
| 19 | + flows = flows, |
| 20 | + mapboxAccessToken = mapboxAccessToken, |
| 21 | + clustering = clustering, |
| 22 | + animation = animation, |
| 23 | + darkMode = darkMode |
| 24 | + ) |
| 25 | + |
| 26 | + # create widget |
| 27 | + htmlwidgets::createWidget( |
| 28 | + name = 'flowmapblue', |
| 29 | + x, |
| 30 | + width = NULL, |
| 31 | + height = NULL, |
| 32 | + package = 'flowmapblue' |
| 33 | + ) |
| 34 | +} |
| 35 | + |
| 36 | +#' Shiny bindings for flowmapblue |
| 37 | +#' |
| 38 | +#' Output and render functions for using flowmapblue within Shiny |
| 39 | +#' applications and interactive Rmd documents. |
| 40 | +#' |
| 41 | +#' @param outputId output variable to read from |
| 42 | +#' @param width,height Must be a valid CSS unit (like \code{'100\%'}, |
| 43 | +#' \code{'400px'}, \code{'auto'}) or a number, which will be coerced to a |
| 44 | +#' string and have \code{'px'} appended. |
| 45 | +#' @param expr An expression that generates a flowmapblue |
| 46 | +#' @param env The environment in which to evaluate \code{expr}. |
| 47 | +#' @param quoted Is \code{expr} a quoted expression (with \code{quote()})? This |
| 48 | +#' is useful if you want to save an expression in a variable. |
| 49 | +#' |
| 50 | +#' @name flowmapblue-shiny |
| 51 | +#' |
| 52 | +#' @export |
| 53 | +flowmapblueOutput <- function(outputId, width = '100%', height = '400px'){ |
| 54 | + htmlwidgets::shinyWidgetOutput(outputId, 'flowmapblue', width, height, package = 'flowmapblue') |
| 55 | +} |
| 56 | + |
| 57 | +#' @rdname flowmapblue-shiny |
| 58 | +#' @export |
| 59 | +renderFlowmapblue <- function(expr, env = parent.frame(), quoted = FALSE) { |
| 60 | + if (!quoted) { expr <- substitute(expr) } # force quoted |
| 61 | + htmlwidgets::shinyRenderWidget(expr, flowmapblueOutput, env, quoted = TRUE) |
| 62 | +} |
0 commit comments