updated docs
This commit is contained in:
parent
f4215fdf37
commit
4f4142211b
29
R/apex.R
29
R/apex.R
|
@ -5,28 +5,23 @@
|
||||||
#' data, mapping and type of chart.
|
#' data, mapping and type of chart.
|
||||||
#'
|
#'
|
||||||
#' @param data Default dataset to use for chart. If not already
|
#' @param data Default dataset to use for chart. If not already
|
||||||
#' a \code{data.frame}, it will be coerced to with \code{as.data.frame}.
|
#' a `data.frame`, it will be coerced to with `as.data.frame`.
|
||||||
#' @param mapping Default list of aesthetic mappings to use for chart
|
#' @param mapping Default list of aesthetic mappings to use for chart
|
||||||
#' @param type Specify the chart type. Available options:
|
#' @param type Specify the chart type. Available options:
|
||||||
#' \code{"column"}, \code{"bar"},
|
#' `"column"`, `"bar"`,
|
||||||
#' \code{"line"}, \code{"step"}, \code{"spline"},
|
#' `"line"`, `"step"`, `"spline"`,
|
||||||
#' \code{"area"}, \code{"area-step"}, \code{"area-spline"},
|
#' `"area"`, `"area-step"`, `"area-spline"`,
|
||||||
#' \code{"pie"}, \code{"donut"},
|
#' `"pie"`, `"donut"`,
|
||||||
#' \code{"radialBar"}, \code{"radar"}, \code{"scatter"},
|
#' `"radialBar"`, `"radar"`, `"scatter"`,
|
||||||
#' \code{"heatmap"}, \code{"treemap"},
|
#' `"heatmap"`, `"treemap"`,
|
||||||
#' \code{"timeline"}.
|
#' `"timeline"`.
|
||||||
#' @param ... Other arguments passed on to methods. Not currently used.
|
#' @param ... Other arguments passed on to methods. Not currently used.
|
||||||
#' @param auto_update In Shiny application, update existing chart
|
|
||||||
#' rather than generating new one. Can be \code{TRUE}/\code{FALSE} or
|
|
||||||
#' use \code{\link{config_update}} for more control.
|
|
||||||
#' @param synchronize Give a common id to charts to synchronize them (tooltip and zoom).
|
#' @param synchronize Give a common id to charts to synchronize them (tooltip and zoom).
|
||||||
#' @param serie_name Name for the serie displayed in tooltip,
|
#' @param serie_name Name for the serie displayed in tooltip,
|
||||||
#' only used for single serie.
|
#' only used for single serie.
|
||||||
#' @param width A numeric input in pixels.
|
#' @inheritParams apexchart
|
||||||
#' @param height A numeric input in pixels.
|
|
||||||
#' @param elementId Use an explicit element ID for the widget.
|
|
||||||
#'
|
#'
|
||||||
#' @return A \code{apexcharts} \code{htmlwidget} object.
|
#' @return An [apexchart()] `htmlwidget` object.
|
||||||
#'
|
#'
|
||||||
#' @export
|
#' @export
|
||||||
#'
|
#'
|
||||||
|
@ -35,7 +30,9 @@
|
||||||
#' @importFrom stats complete.cases
|
#' @importFrom stats complete.cases
|
||||||
#'
|
#'
|
||||||
#' @example examples/apex.R
|
#' @example examples/apex.R
|
||||||
apex <- function(data, mapping, type = "column", ...,
|
apex <- function(data, mapping,
|
||||||
|
type = "column",
|
||||||
|
...,
|
||||||
auto_update = TRUE,
|
auto_update = TRUE,
|
||||||
synchronize = NULL,
|
synchronize = NULL,
|
||||||
serie_name = NULL,
|
serie_name = NULL,
|
||||||
|
|
|
@ -1,22 +1,26 @@
|
||||||
|
|
||||||
#' Create an apexcharts.js widget
|
#' Create an ApexCharts widget
|
||||||
#'
|
#'
|
||||||
#' @param ax_opts A \code{list} in JSON format with chart parameters.
|
#' @param ax_opts A `list` in JSON format with chart parameters.
|
||||||
#' @param auto_update In Shiny application, update existing chart
|
#' @param auto_update In Shiny application, update existing chart
|
||||||
#' rather than generating new one. Can be \code{TRUE}/\code{FALSE} or
|
#' rather than generating new one. Can be `TRUE`/`FALSE` or
|
||||||
#' use \code{\link{config_update}} for more control.
|
#' use [config_update()] for more control.
|
||||||
#' @param width A numeric input in pixels.
|
#' @param width,height A numeric input in pixels.
|
||||||
#' @param height A numeric input in pixels.
|
|
||||||
#' @param elementId Use an explicit element ID for the widget.
|
#' @param elementId Use an explicit element ID for the widget.
|
||||||
#'
|
#'
|
||||||
#' @return A \code{apexcharts} \code{htmlwidget} object.
|
#' @return An [apexchart()] `htmlwidget` object.
|
||||||
|
#' @seealso For quickly create a chart, see [apex()].
|
||||||
#' @export
|
#' @export
|
||||||
#'
|
#'
|
||||||
#' @importFrom htmlwidgets createWidget sizingPolicy
|
#' @importFrom htmlwidgets createWidget sizingPolicy
|
||||||
#'
|
#'
|
||||||
#' @example examples/apexchart.R
|
#' @example examples/apexchart.R
|
||||||
apexchart <- function(ax_opts = list(), auto_update = TRUE, width = NULL, height = NULL, elementId = NULL) {
|
apexchart <- function(ax_opts = list(),
|
||||||
|
auto_update = TRUE,
|
||||||
|
width = NULL,
|
||||||
|
height = NULL,
|
||||||
|
elementId = NULL) {
|
||||||
|
|
||||||
if (isTRUE(auto_update)) {
|
if (isTRUE(auto_update)) {
|
||||||
auto_update <- config_update()
|
auto_update <- config_update()
|
||||||
}
|
}
|
||||||
|
@ -63,9 +67,9 @@ add_locale_apex <- function(widget) {
|
||||||
defaultLocale <- widget$x$ax_opts$chart$defaultLocale
|
defaultLocale <- widget$x$ax_opts$chart$defaultLocale
|
||||||
defaultLocale <- match.arg(
|
defaultLocale <- match.arg(
|
||||||
arg = defaultLocale,
|
arg = defaultLocale,
|
||||||
choices = c("ca", "cs", "de", "el", "en", "es", "fi", "fr", "he", "hi",
|
choices = c("ca", "cs", "de", "el", "en", "es", "fi", "fr", "he", "hi",
|
||||||
"hr", "hu", "hy", "id", "it", "ja", "ka", "ko", "lt", "nb", "nl",
|
"hr", "hu", "hy", "id", "it", "ja", "ka", "ko", "lt", "nb", "nl",
|
||||||
"pl", "pt-br", "pt", "rs", "ru", "se", "sk", "sl", "sq", "th",
|
"pl", "pt-br", "pt", "rs", "ru", "se", "sk", "sl", "sq", "th",
|
||||||
"tr", "ua", "zh-cn")
|
"tr", "ua", "zh-cn")
|
||||||
)
|
)
|
||||||
if (!is.null(widget$x$ax_opts$chart$locales)) {
|
if (!is.null(widget$x$ax_opts$chart$locales)) {
|
||||||
|
@ -93,22 +97,22 @@ add_locale_apex <- function(widget) {
|
||||||
#' @param update_options Update or not global options for chart.
|
#' @param update_options Update or not global options for chart.
|
||||||
#' @param options_animate Should the chart animate on re-rendering.
|
#' @param options_animate Should the chart animate on re-rendering.
|
||||||
#' @param options_redrawPaths When the chart is re-rendered,
|
#' @param options_redrawPaths When the chart is re-rendered,
|
||||||
#' should it draw from the existing paths or completely redraw
|
#' should it draw from the existing paths or completely redraw
|
||||||
#' the chart paths from the beginning. By default, the chart
|
#' the chart paths from the beginning. By default, the chart
|
||||||
#' is re-rendered from the existing paths.
|
#' is re-rendered from the existing paths.
|
||||||
#' @param update_synced_charts All the charts in a group should
|
#' @param update_synced_charts All the charts in a group should
|
||||||
#' also update when one chart in a group is updated.
|
#' also update when one chart in a group is updated.
|
||||||
#'
|
#'
|
||||||
#' @export
|
#' @export
|
||||||
config_update <- function(series_animate = TRUE,
|
config_update <- function(series_animate = TRUE,
|
||||||
update_options = FALSE,
|
update_options = FALSE,
|
||||||
options_animate = TRUE,
|
options_animate = TRUE,
|
||||||
options_redrawPaths = TRUE,
|
options_redrawPaths = TRUE,
|
||||||
update_synced_charts = FALSE) {
|
update_synced_charts = FALSE) {
|
||||||
list(
|
list(
|
||||||
series_animate = series_animate,
|
series_animate = series_animate,
|
||||||
update_options = update_options,
|
update_options = update_options,
|
||||||
options_animate = options_animate,
|
options_animate = options_animate,
|
||||||
options_redrawPaths = options_redrawPaths,
|
options_redrawPaths = options_redrawPaths,
|
||||||
update_synced_charts = update_synced_charts
|
update_synced_charts = update_synced_charts
|
||||||
)
|
)
|
||||||
|
@ -120,23 +124,26 @@ config_update <- function(series_animate = TRUE,
|
||||||
#' @description Output and render functions for using apexcharter within Shiny
|
#' @description Output and render functions for using apexcharter within Shiny
|
||||||
#' applications and interactive Rmd documents.
|
#' applications and interactive Rmd documents.
|
||||||
#'
|
#'
|
||||||
#' @param outputId output variable to read from
|
#' @param outputId Output variable to read from.
|
||||||
#' @param width,height Must be a valid CSS unit (like \code{'100\%'},
|
#' @param width,height Must be a valid CSS unit (like `100%`,
|
||||||
#' \code{'400px'}, \code{'auto'}) or a number, which will be coerced to a
|
#' `400px`, `auto`) or a number, which will be coerced to a
|
||||||
#' string and have \code{'px'} appended.
|
#' string and have `px` appended.
|
||||||
#' @param expr An expression that generates a apexcharter
|
#' @param expr An expression that generates a calendar
|
||||||
#' @param env The environment in which to evaluate \code{expr}.
|
#' @param env The environment in which to evaluate `expr`.
|
||||||
#' @param quoted Is \code{expr} a quoted expression (with \code{quote()})? This
|
#' @param quoted Is `expr` a quoted expression (with `quote()`)? This
|
||||||
#' is useful if you want to save an expression in a variable.
|
#' is useful if you want to save an expression in a variable.
|
||||||
#'
|
#'
|
||||||
#' @return An Apexcharts output that can be included in the application UI.
|
#' @return Output element that can be included in UI. Render function to create output in server.
|
||||||
|
#'
|
||||||
|
#' @note To render a chart with facets (using [ax_facet_wrap()] or [ax_facet_grid()]) in Shiny,
|
||||||
|
#' see [apexfacetOutput()] (in UI) and [renderApexfacet()] (in Server).
|
||||||
#'
|
#'
|
||||||
#' @name apexcharter-shiny
|
#' @name apexcharter-shiny
|
||||||
#'
|
#'
|
||||||
#' @export
|
#' @export
|
||||||
#'
|
#'
|
||||||
#' @importFrom htmlwidgets shinyWidgetOutput shinyRenderWidget
|
#' @importFrom htmlwidgets shinyWidgetOutput shinyRenderWidget
|
||||||
#'
|
#'
|
||||||
#' @example examples/apexcharter-shiny.R
|
#' @example examples/apexcharter-shiny.R
|
||||||
apexchartOutput <- function(outputId, width = "100%", height = "400px") { # nocov start
|
apexchartOutput <- function(outputId, width = "100%", height = "400px") { # nocov start
|
||||||
htmlwidgets::shinyWidgetOutput(outputId, "apexcharter", width, height, package = "apexcharter")
|
htmlwidgets::shinyWidgetOutput(outputId, "apexcharter", width, height, package = "apexcharter")
|
||||||
|
|
|
@ -36,7 +36,7 @@ a \code{data.frame}, it will be coerced to with \code{as.data.frame}.}
|
||||||
|
|
||||||
\item{auto_update}{In Shiny application, update existing chart
|
\item{auto_update}{In Shiny application, update existing chart
|
||||||
rather than generating new one. Can be \code{TRUE}/\code{FALSE} or
|
rather than generating new one. Can be \code{TRUE}/\code{FALSE} or
|
||||||
use \code{\link{config_update}} for more control.}
|
use \code{\link[=config_update]{config_update()}} for more control.}
|
||||||
|
|
||||||
\item{synchronize}{Give a common id to charts to synchronize them (tooltip and zoom).}
|
\item{synchronize}{Give a common id to charts to synchronize them (tooltip and zoom).}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ only used for single serie.}
|
||||||
\item{elementId}{Use an explicit element ID for the widget.}
|
\item{elementId}{Use an explicit element ID for the widget.}
|
||||||
}
|
}
|
||||||
\value{
|
\value{
|
||||||
A \code{apexcharts} \code{htmlwidget} object.
|
An \code{\link[=apexchart]{apexchart()}} \code{htmlwidget} object.
|
||||||
}
|
}
|
||||||
\description{
|
\description{
|
||||||
Initialize a chart with three main parameters :
|
Initialize a chart with three main parameters :
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
% Please edit documentation in R/apexcharter.R
|
% Please edit documentation in R/apexcharter.R
|
||||||
\name{apexchart}
|
\name{apexchart}
|
||||||
\alias{apexchart}
|
\alias{apexchart}
|
||||||
\title{Create an apexcharts.js widget}
|
\title{Create an ApexCharts widget}
|
||||||
\usage{
|
\usage{
|
||||||
apexchart(
|
apexchart(
|
||||||
ax_opts = list(),
|
ax_opts = list(),
|
||||||
|
@ -17,19 +17,17 @@ apexchart(
|
||||||
|
|
||||||
\item{auto_update}{In Shiny application, update existing chart
|
\item{auto_update}{In Shiny application, update existing chart
|
||||||
rather than generating new one. Can be \code{TRUE}/\code{FALSE} or
|
rather than generating new one. Can be \code{TRUE}/\code{FALSE} or
|
||||||
use \code{\link{config_update}} for more control.}
|
use \code{\link[=config_update]{config_update()}} for more control.}
|
||||||
|
|
||||||
\item{width}{A numeric input in pixels.}
|
\item{width, height}{A numeric input in pixels.}
|
||||||
|
|
||||||
\item{height}{A numeric input in pixels.}
|
|
||||||
|
|
||||||
\item{elementId}{Use an explicit element ID for the widget.}
|
\item{elementId}{Use an explicit element ID for the widget.}
|
||||||
}
|
}
|
||||||
\value{
|
\value{
|
||||||
A \code{apexcharts} \code{htmlwidget} object.
|
An \code{\link[=apexchart]{apexchart()}} \code{htmlwidget} object.
|
||||||
}
|
}
|
||||||
\description{
|
\description{
|
||||||
Create an apexcharts.js widget
|
Create an ApexCharts widget
|
||||||
}
|
}
|
||||||
\examples{
|
\examples{
|
||||||
library(apexcharter)
|
library(apexcharter)
|
||||||
|
@ -66,3 +64,6 @@ apexchart() \%>\%
|
||||||
categories = LETTERS[1:5]
|
categories = LETTERS[1:5]
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
\seealso{
|
||||||
|
For quickly create a chart, see \code{\link[=apex]{apex()}}.
|
||||||
|
}
|
||||||
|
|
|
@ -17,13 +17,13 @@ sparkBoxOutput(outputId, width = "100\%", height = "160px")
|
||||||
renderSparkBox(expr, env = parent.frame(), quoted = FALSE)
|
renderSparkBox(expr, env = parent.frame(), quoted = FALSE)
|
||||||
}
|
}
|
||||||
\arguments{
|
\arguments{
|
||||||
\item{outputId}{output variable to read from}
|
\item{outputId}{Output variable to read from.}
|
||||||
|
|
||||||
\item{width, height}{Must be a valid CSS unit (like \code{'100\%'},
|
\item{width, height}{Must be a valid CSS unit (like \verb{100\%},
|
||||||
\code{'400px'}, \code{'auto'}) or a number, which will be coerced to a
|
\verb{400px}, \code{auto}) or a number, which will be coerced to a
|
||||||
string and have \code{'px'} appended.}
|
string and have \code{px} appended.}
|
||||||
|
|
||||||
\item{expr}{An expression that generates a apexcharter}
|
\item{expr}{An expression that generates a calendar}
|
||||||
|
|
||||||
\item{env}{The environment in which to evaluate \code{expr}.}
|
\item{env}{The environment in which to evaluate \code{expr}.}
|
||||||
|
|
||||||
|
@ -31,12 +31,16 @@ string and have \code{'px'} appended.}
|
||||||
is useful if you want to save an expression in a variable.}
|
is useful if you want to save an expression in a variable.}
|
||||||
}
|
}
|
||||||
\value{
|
\value{
|
||||||
An Apexcharts output that can be included in the application UI.
|
Output element that can be included in UI. Render function to create output in server.
|
||||||
}
|
}
|
||||||
\description{
|
\description{
|
||||||
Output and render functions for using apexcharter within Shiny
|
Output and render functions for using apexcharter within Shiny
|
||||||
applications and interactive Rmd documents.
|
applications and interactive Rmd documents.
|
||||||
}
|
}
|
||||||
|
\note{
|
||||||
|
To render a chart with facets (using \code{\link[=ax_facet_wrap]{ax_facet_wrap()}} or \code{\link[=ax_facet_grid]{ax_facet_grid()}}) in Shiny,
|
||||||
|
see \code{\link[=apexfacetOutput]{apexfacetOutput()}} (in UI) and \code{\link[=renderApexfacet]{renderApexfacet()}} (in Server).
|
||||||
|
}
|
||||||
\examples{
|
\examples{
|
||||||
if (interactive()) {
|
if (interactive()) {
|
||||||
library(shiny)
|
library(shiny)
|
||||||
|
|
Loading…
Reference in New Issue