From 481930aabe9d6eae1a974b9b66294995180bc9f1 Mon Sep 17 00:00:00 2001 From: pvictor Date: Fri, 15 Feb 2019 22:33:14 +0100 Subject: [PATCH] rename fun --- NAMESPACE | 2 +- R/apex-utils.R | 4 ++-- R/apex.R | 2 +- R/apexcharter.R | 12 ++++++------ README.md | 4 ++-- dev/raw-api.R | 4 ++-- inst/examples/barcharts.R | 8 ++++---- inst/examples/heatmap.R | 6 +++--- inst/examples/pie.R | 4 ++-- inst/examples/proxy-update-serie-line.R | 2 +- inst/examples/radial.R | 6 +++--- inst/examples/timeseries.R | 6 +++--- man/{apexcharter.Rd => apexchart.Rd} | 12 ++++++------ man/ax-series.Rd | 4 ++-- 14 files changed, 38 insertions(+), 38 deletions(-) rename man/{apexcharter.Rd => apexchart.Rd} (72%) diff --git a/NAMESPACE b/NAMESPACE index b806d6a..4229d1a 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -3,9 +3,9 @@ export("%>%") export(aes) export(apex) +export(apexchart) export(apexchartOutput) export(apexchartProxy) -export(apexcharter) export(ax_annotations) export(ax_chart) export(ax_colors) diff --git a/R/apex-utils.R b/R/apex-utils.R index 4b5e3a3..d428143 100644 --- a/R/apex-utils.R +++ b/R/apex-utils.R @@ -384,14 +384,14 @@ ax_responsive <- function(ax, ...) { #' @examples #' #' # One serie -#' apexcharter() %>% +#' apexchart() %>% #' ax_series(list( #' name = "rnorm", #' data = rnorm(10) #' )) #' #' # Two series -#' apexcharter() %>% +#' apexchart() %>% #' ax_series( #' list( #' name = "rnorm 1", diff --git a/R/apex.R b/R/apex.R index 5b26689..21c35aa 100644 --- a/R/apex.R +++ b/R/apex.R @@ -33,7 +33,7 @@ apex <- function(data, mapping, type = "column", ..., width = NULL, height = NUL ) } opts <- modifyList(opts, choose_config(type, is_datetime(mapdata))) - apexcharter(ax_opts = opts, width = width, height = height, elementId = elementId) + apexchart(ax_opts = opts, width = width, height = height, elementId = elementId) } diff --git a/R/apexcharter.R b/R/apexcharter.R index 66fafc2..b1beab9 100644 --- a/R/apexcharter.R +++ b/R/apexcharter.R @@ -1,8 +1,8 @@ #' Create a apexcharts.js widget #' -#' @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}. -#' @param ax_opts A \code{list} in JSON format with chart parameters.#' +#' @param ax_opts A \code{list} in JSON format with chart parameters. +#' @param auto_update In Shiny application, update existing chart rather than generating new one. #' @param width A numeric input in pixels. #' @param height A numeric input in pixels. #' @param elementId Use an explicit element ID for the widget. @@ -16,7 +16,7 @@ #' #' library(apexcharter) #' -#' apexcharter(ax_opts = list( +#' apexchart(ax_opts = list( #' chart = list(type = "bar"), #' series = list(list( #' name = "Example", @@ -24,18 +24,18 @@ #' )), #' xaxis = list(categories = LETTERS[1:5]) #' )) -apexcharter <- function(data = NULL, ax_opts = list(), width = NULL, height = NULL, elementId = NULL) { +apexchart <- function(ax_opts = list(), auto_update = TRUE, width = NULL, height = NULL, elementId = NULL) { # forward options using x x <- list( ax_opts = ax_opts, - data = as.data.frame(data) + auto_update = auto_update ) # create widget htmlwidgets::createWidget( name = 'apexcharter', - x, + x = x, width = width, height = height, package = 'apexcharter', diff --git a/README.md b/README.md index 0931500..ae6d574 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ library(apexcharter) data(mpg, package = "ggplot2") n_manufac <- dplyr::count(mpg, manufacturer) -apexcharter() %>% +apexchart() %>% ax_chart(type = "bar") %>% ax_plotOptions(bar = barOpts( horizontal = FALSE, @@ -92,7 +92,7 @@ apexcharter() %>% Pass a list of parameters to the function: ``` r -apexcharter(ax_opts = list( +apexchart(ax_opts = list( chart = list( type = "line" ), diff --git a/dev/raw-api.R b/dev/raw-api.R index 92c9956..660ad81 100644 --- a/dev/raw-api.R +++ b/dev/raw-api.R @@ -13,7 +13,7 @@ library(dplyr) data(mpg) dat <- count(mpg, manufacturer) -apexcharter(ax_opts = list( +apexchart(ax_opts = list( chart = list(type = "bar"), plotOptions = list( bar = list( @@ -43,7 +43,7 @@ apexcharter(ax_opts = list( # recreating (mostly): https://apexcharts.com/javascript-chart-demos/line-charts/data-labels/ -apexcharter(ax_opts = list( +apexchart(ax_opts = list( chart = list( type = "line" ), diff --git a/inst/examples/barcharts.R b/inst/examples/barcharts.R index 9e09b71..f4bc3ad 100644 --- a/inst/examples/barcharts.R +++ b/inst/examples/barcharts.R @@ -23,7 +23,7 @@ library(dplyr) # for count data(mpg) dat <- count(mpg, manufacturer) -apexcharter() %>% +apexchart() %>% ax_chart(type = "bar") %>% ax_plotOptions(bar = barOpts( horizontal = FALSE, @@ -55,7 +55,7 @@ apexcharter() %>% data(mpg) dat <- count(mpg, manufacturer) -apexcharter() %>% +apexchart() %>% ax_chart(type = "bar") %>% ax_plotOptions(bar = barOpts( horizontal = TRUE, @@ -86,7 +86,7 @@ apexcharter() %>% stacked <- count(mpg, manufacturer, year) -apexcharter() %>% +apexchart() %>% ax_chart(type = "bar", stacked = TRUE) %>% ax_series( list( @@ -113,7 +113,7 @@ apexcharter() %>% stacked <- count(mpg, manufacturer, year) -apexcharter() %>% +apexchart() %>% ax_chart(type = "bar", stacked = FALSE) %>% ax_plotOptions(bar = barOpts( endingShape = "rounded" diff --git a/inst/examples/heatmap.R b/inst/examples/heatmap.R index 3fe4e5c..725d0ae 100644 --- a/inst/examples/heatmap.R +++ b/inst/examples/heatmap.R @@ -28,7 +28,7 @@ mtcars_long <- mtcars %>% mtcars_long$value <- round(mtcars_long$value) -test <- apexcharter() %>% +test <- apexchart() %>% ax_chart(type = "heatmap") %>% ax_dataLabels(enabled = FALSE) %>% ax_series2(lapply( @@ -46,7 +46,7 @@ test <- apexcharter() %>% ax_xaxis(type = "category", categories = unique(mtcars_long$variable)) -apexcharter() %>% +apexchart() %>% ax_chart(type = "heatmap") %>% ax_dataLabels(enabled = FALSE) %>% ax_series2(l = list( @@ -74,7 +74,7 @@ apexcharter() %>% data("vaccines", package = "highcharter") -apexcharter() %>% +apexchart() %>% ax_chart(type = "heatmap", animations = list(enabled = FALSE)) %>% ax_dataLabels(enabled = FALSE) %>% ax_series2(lapply( diff --git a/inst/examples/pie.R b/inst/examples/pie.R index 020985e..8a93921 100644 --- a/inst/examples/pie.R +++ b/inst/examples/pie.R @@ -20,7 +20,7 @@ library(apexcharter) # Simple pie -------------------------------------------------------------- -apexcharter() %>% +apexchart() %>% ax_chart(type = "pie") %>% ax_series(23, 45, 56) %>% ax_labels("A", "B", "C") @@ -31,7 +31,7 @@ apexcharter() %>% # Donut ------------------------------------------------------------------- -apexcharter() %>% +apexchart() %>% ax_chart(type = "donut") %>% ax_series2(c(23, 45, 56)) %>% ax_labels2(c("A", "B", "C")) diff --git a/inst/examples/proxy-update-serie-line.R b/inst/examples/proxy-update-serie-line.R index b396fed..6e09fe3 100644 --- a/inst/examples/proxy-update-serie-line.R +++ b/inst/examples/proxy-update-serie-line.R @@ -23,7 +23,7 @@ ui <- fluidPage( server <- function(input, output, session) { output$graph <- renderApexchart({ - apexcharter() %>% + apexchart() %>% ax_chart(type = "line") %>% ax_plotOptions(line = list(curve = "smooth")) %>% ax_dataLabels(enabled = FALSE) %>% diff --git a/inst/examples/radial.R b/inst/examples/radial.R index be685ca..c7efb2e 100644 --- a/inst/examples/radial.R +++ b/inst/examples/radial.R @@ -20,7 +20,7 @@ library(apexcharter) # Basic ------------------------------------------------------------------- -apexcharter() %>% +apexchart() %>% ax_chart(type = "radialBar") %>% ax_plotOptions( radialBar = radialBarOpts( @@ -35,7 +35,7 @@ apexcharter() %>% # Stroked gauge ----------------------------------------------------------- -apexcharter() %>% +apexchart() %>% ax_chart(type = "radialBar") %>% ax_plotOptions( radialBar = radialBarOpts( @@ -64,7 +64,7 @@ apexcharter() %>% -apexcharter() %>% +apexchart() %>% ax_chart(type = "radialBar") %>% # ax_plotOptions( # radialBar = radialBarOpts( diff --git a/inst/examples/timeseries.R b/inst/examples/timeseries.R index ac8d018..baae2d5 100644 --- a/inst/examples/timeseries.R +++ b/inst/examples/timeseries.R @@ -25,7 +25,7 @@ data("economics", package = "ggplot2") # One serie (class Date) -------------------------------------------------- -apexcharter() %>% +apexchart() %>% ax_chart(type = "area", zoom = list(enabled = TRUE)) %>% # ax_stroke(curve = "smooth") %>% ax_plotOptions(line = list(curve = "smooth")) %>% @@ -62,7 +62,7 @@ apexcharter() %>% # Two series (Date) ------------------------------------------------------- -apexcharter() %>% +apexchart() %>% ax_chart(type = "line", zoom = list(enabled = TRUE)) %>% ax_plotOptions(line = list(curve = "smooth")) %>% ax_dataLabels(enabled = FALSE) %>% @@ -99,7 +99,7 @@ apexcharter() %>% # doesn't work since 2.0.0 -apexcharter() %>% +apexchart() %>% ax_chart(type = "area", scroller = list(enabled = TRUE)) %>% ax_dataLabels(enabled = FALSE) %>% ax_series(list( diff --git a/man/apexcharter.Rd b/man/apexchart.Rd similarity index 72% rename from man/apexcharter.Rd rename to man/apexchart.Rd index 2a93792..0bfec7b 100644 --- a/man/apexcharter.Rd +++ b/man/apexchart.Rd @@ -1,16 +1,16 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/apexcharter.R -\name{apexcharter} -\alias{apexcharter} +\name{apexchart} +\alias{apexchart} \title{Create a apexcharts.js widget} \usage{ -apexcharter(data = NULL, ax_opts = list(), width = NULL, +apexchart(ax_opts = list(), auto_update = TRUE, width = NULL, height = NULL, elementId = NULL) } \arguments{ -\item{data}{Default dataset to use for chart. If not already a \code{data.frame}, it will be coerced to with \code{as.data.frame}.} +\item{ax_opts}{A \code{list} in JSON format with chart parameters.} -\item{ax_opts}{A \code{list} in JSON format with chart parameters.#'} +\item{auto_update}{In Shiny application, update existing chart rather than generating new one.} \item{width}{A numeric input in pixels.} @@ -28,7 +28,7 @@ Create a apexcharts.js widget library(apexcharter) -apexcharter(ax_opts = list( +apexchart(ax_opts = list( chart = list(type = "bar"), series = list(list( name = "Example", diff --git a/man/ax-series.Rd b/man/ax-series.Rd index 9b944f2..50cbc14 100644 --- a/man/ax-series.Rd +++ b/man/ax-series.Rd @@ -26,14 +26,14 @@ Add data to a chart \examples{ # One serie -apexcharter() \%>\% +apexchart() \%>\% ax_series(list( name = "rnorm", data = rnorm(10) )) # Two series -apexcharter() \%>\% +apexchart() \%>\% ax_series( list( name = "rnorm 1",