#' <Add Title>
#'
#' <Add Description>
#'
#' @import htmlwidgets
#'
#' @export
C3Pie <- function(values, legendPosition = "bottom",
color_pattern = c('#155263', '#49beb7', '#ef255f', '#17b978', '#f07b3f', '#734488', '#17b978', '#d62728', '#ff9896', '#9467bd', '#c5b0d5', '#8c564b', '#c49c94', '#e377c2', '#f7b6d2', '#7f7f7f', '#c7c7c7', '#bcbd22', '#dbdb8d', '#17becf', '#9edae5'),
width = 'auto', height = 'auto') {
# forward options using x
x = list(
values = values,
legendPosition = legendPosition,
color_pattern = color_pattern
)
# create widget
htmlwidgets::createWidget(
name = 'C3Pie',
x,
width = width,
height = height,
package = 'C3'
)
}
#' Shiny bindings for C3Pie
#'
#' Output and render functions for using C3Pie within Shiny
#' applications and interactive Rmd documents.
#'
#' @param outputId output variable to read from
#' @param width,height Must be a valid CSS unit (like \code{'100\%'},
#' \code{'400px'}, \code{'auto'}) or a number, which will be coerced to a
#' string and have \code{'px'} appended.
#' @param expr An expression that generates a C3Pie
#' @param env The environment in which to evaluate \code{expr}.
#' @param quoted Is \code{expr} a quoted expression (with \code{quote()})? This
#' is useful if you want to save an expression in a variable.
#'
#' @name C3Pie-shiny
#'
#' @export
C3PieOutput <- function(outputId, width = '100%', height = '400px'){
htmlwidgets::shinyWidgetOutput(outputId, 'C3Pie', width, height, package = 'C3')
}
#' @rdname C3Pie-shiny
#' @export
renderC3Pie <- function(expr, env = parent.frame(), quoted = FALSE) {
if (!quoted) { expr <- substitute(expr) } # force quoted
htmlwidgets::shinyRenderWidget(expr, C3PieOutput, env, quoted = TRUE)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.