From 2043f885623794265c7f5cf0d5f0efd8baa6ae59 Mon Sep 17 00:00:00 2001 From: pvictor Date: Wed, 24 Jul 2019 12:20:22 +0200 Subject: [PATCH] prepare to resubmit --- .Rbuildignore | 1 + DESCRIPTION | 10 +++-- LICENSE | 32 +-------------- R/apex-options.R | 76 +++++++++++++++++++++++++++++++----- R/apex.R | 6 ++- R/apexcharter.R | 6 ++- R/parse-data.R | 14 +++++++ cran-comments.md | 10 ++++- inst/htmlwidgets/lib/LICENSE | 24 ++++++++++++ man/apex.Rd | 7 +++- man/apexcharter-shiny.Rd | 3 ++ man/bar_opts.Rd | 3 ++ man/events_opts.Rd | 52 ++++++++++++++++++++++++ man/heatmap_opts.Rd | 3 ++ man/parse_df.Rd | 16 ++++++++ man/pie_opts.Rd | 3 ++ man/radialBar_opts.Rd | 3 ++ 17 files changed, 218 insertions(+), 51 deletions(-) create mode 100644 inst/htmlwidgets/lib/LICENSE diff --git a/.Rbuildignore b/.Rbuildignore index 3511a64..c8f91ef 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -7,3 +7,4 @@ ^_pkgdown\.yml$ ^docs$ ^cran-comments\.md$ +^CRAN-RELEASE$ diff --git a/DESCRIPTION b/DESCRIPTION index 1a04917..20b67a7 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,11 +1,13 @@ Package: apexcharter -Version: 0.1.0 +Version: 0.1.1 Title: Create Interactive Chart with the JavaScript 'ApexCharts' Library -Description: Provides an 'htmlwidgets' interface to 'apexcharts.js'. +Description: Provides an 'htmlwidgets' interface to 'apexcharts.js'. + 'Apexcharts' is a modern JavaScript charting library to build interactive charts and visualizations with simple API. + 'Apexcharts' examples and documentation are available here: . Authors@R: c( person("Victor", "Perrier", email = "victor.perrier@dreamrs.fr", role = c("aut", "cre")), - person("Fanny", "Meyer", email = "fanny.meyer@dreamrs.fr", role = c("aut")), - person("Juned", "Chhipa", role = c("cph"), comment = "apexcharts.js library")) + person("Fanny", "Meyer", email = "fanny.meyer@dreamrs.fr", role = "aut"), + person("Juned", "Chhipa", role = "cph", comment = "apexcharts.js library")) License: MIT + file LICENSE Encoding: UTF-8 LazyData: true diff --git a/LICENSE b/LICENSE index cfb3803..9adf9ad 100644 --- a/LICENSE +++ b/LICENSE @@ -1,32 +1,2 @@ -R PACKAGE -========= - YEAR: 2019 -COPYRIGHT HOLDER: dreamRs - - -ApexCharts.js -============= - -The MIT License (MIT) - -Copyright (c) 2018 ApexCharts - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - +COPYRIGHT HOLDER: Victor Perrier diff --git a/R/apex-options.R b/R/apex-options.R index 0d6f69f..b3c5e38 100644 --- a/R/apex-options.R +++ b/R/apex-options.R @@ -23,11 +23,61 @@ #' @param ... Additional parameters. #' #' @note All arguments should be JavaScript function defined with \code{htmlwidgets::JS}. +#' +#' @return A \code{list} of options that can be used in \code{\link{ax_chart}}. #' #' @note See \url{https://apexcharts.com/docs/options/chart/events/}. #' #' @export -#' +#' +#' @examples +#' +#' if (interactive()) { +#' library(shiny) +#' +#' ui <- fluidPage( +#' fluidRow( +#' column( +#' width = 8, offset = 2, +#' tags$h2("Apexchart in Shiny"), +#' apexchartOutput("chart"), +#' verbatimTextOutput(outputId = "res_click") +#' ) +#' ) +#' ) +#' +#' server <- function(input, output, session) { +#' +#' output$chart <- renderApexchart({ +#' apexchart() %>% +#' ax_chart( +#' type = "bar", +#' events = events_opts( +#' dataPointSelection = JS( +#' "function(event, chartContext, config) { +#' Shiny.setInputValue('click', config.selectedDataPoints) +#' }" +#' ) +#' ) +#' ) %>% +#' ax_series( +#' list( +#' name = "Example", +#' data = sample(1:100, 5) +#' ) +#' ) %>% +#' ax_xaxis( +#' categories = LETTERS[1:5] +#' ) +#' }) +#' +#' output$res_click <- renderPrint({ +#' input$click +#' }) +#' } +#' +#' shinyApp(ui, server) +#' } events_opts <- function(click = NULL, beforeMount = NULL, mounted = NULL, @@ -63,9 +113,9 @@ events_opts <- function(click = NULL, -#' Bar options +#' @title Bar options #' -#' Use these options in \code{\link{ax_plotOptions}}. +#' @description Use these options in \code{\link{ax_plotOptions}}. #' #' @param horizontal Logical. This option will turn a column chart into a horizontal bar chart. #' @param endingShape Available Options: \code{"flat"} or \code{"rounded"}. @@ -77,6 +127,8 @@ events_opts <- function(click = NULL, #' @param ... Additional parameters. #' #' @note See \url{https://apexcharts.com/docs/options/plotoptions/bar/}. +#' +#' @return A \code{list} of options that can be used in \code{\link{ax_plotOptions}}. #' #' @export #' @@ -117,9 +169,9 @@ bar_opts <- function(horizontal = NULL, } -#' Heatmap options +#' @title Heatmap options #' -#' Use these options in \code{\link{ax_plotOptions}}. +#' @description Use these options in \code{\link{ax_plotOptions}}. #' #' @param radius Numeric. Radius of the rectangle inside heatmap. #' @param enableShades Logical. Enable different shades of color depending on the value @@ -128,6 +180,8 @@ bar_opts <- function(horizontal = NULL, #' @param ... Additional parameters. #' #' @note See \url{https://apexcharts.com/docs/options/plotoptions/heatmap/}. +#' +#' @return A \code{list} of options that can be used in \code{\link{ax_plotOptions}}. #' #' @export #' @@ -173,9 +227,9 @@ heatmap_opts <- function(radius = NULL, } -#' Radial bar options +#' @title Radial bar options #' -#' Use these options in \code{\link{ax_plotOptions}}. +#' @description Use these options in \code{\link{ax_plotOptions}}. #' #' @param size Numeric. Manual size of the radialBars instead of calculating automatically from default height / width. #' @param inverseOrder Logical. Whether to make the first value of series innermost or outermost. @@ -189,6 +243,8 @@ heatmap_opts <- function(radius = NULL, #' @param ... Additional parameters. #' #' @note See \url{https://apexcharts.com/docs/options/plotoptions/radialbar/}. +#' +#' @return A \code{list} of options that can be used in \code{\link{ax_plotOptions}}. #' #' @export #' @@ -244,9 +300,9 @@ radialBar_opts <- function(size = NULL, } -#' Pie options +#' @title Pie options #' -#' Use these options in \code{\link{ax_plotOptions}}. +#' @description Use these options in \code{\link{ax_plotOptions}}. #' #' @param size Numeric. Custom size of the pie which will override the default size calculations. #' @param donut List with two fields \code{size} (Donut / ring size in percentage relative to the total pie area.) @@ -258,6 +314,8 @@ radialBar_opts <- function(size = NULL, #' @param ... Additional parameters. #' #' @note See \url{https://apexcharts.com/docs/options/plotoptions/pie/}. +#' +#' @return A \code{list} of options that can be used in \code{\link{ax_plotOptions}}. #' #' @export #' diff --git a/R/apex.R b/R/apex.R index 93d5ab8..2c2030c 100644 --- a/R/apex.R +++ b/R/apex.R @@ -1,5 +1,7 @@ -#' Quick Apex Chart +#' @title Quick ApexChart +#' +#' @description Initialize a chart with three main parameters : data, mapping and type of chart. #' #' @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 mapping Default list of aesthetic mappings to use for chart @@ -10,6 +12,8 @@ #' @param width A numeric input in pixels. #' @param height A numeric input in pixels. #' @param elementId Use an explicit element ID for the widget. +#' +#' @return A \code{apexcharts} \code{htmlwidget} object. #' #' @export #' diff --git a/R/apexcharter.R b/R/apexcharter.R index 87a2464..2aba5d0 100644 --- a/R/apexcharter.R +++ b/R/apexcharter.R @@ -80,9 +80,9 @@ apexchart <- function(ax_opts = list(), auto_update = TRUE, width = NULL, height ) } -#' Shiny bindings for apexcharter +#' @title Shiny bindings for apexcharter #' -#' Output and render functions for using apexcharter within Shiny +#' @description Output and render functions for using apexcharter within Shiny #' applications and interactive Rmd documents. #' #' @param outputId output variable to read from @@ -93,6 +93,8 @@ apexchart <- function(ax_opts = list(), auto_update = TRUE, width = NULL, height #' @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. +#' +#' @return An Apexchart output that can be included in the application UI. #' #' @name apexcharter-shiny #' diff --git a/R/parse-data.R b/R/parse-data.R index f97cd36..bf4bdec 100644 --- a/R/parse-data.R +++ b/R/parse-data.R @@ -6,9 +6,23 @@ #' @param data A \code{data.frame} or an object coercible to \code{data.frame}. #' @param add_names Use names of columns in output. Can be logical to #' reuse \code{data} names or a character vector of new names. +#' +#' @return A \code{list} that can be used to specify data in \code{\link{ax_series}} for example. #' #' @export #' @importFrom stats setNames +#' +#' @examples +#' +#' # All iris dataset +#' parse_df(iris) +#' +#' # Keep variables names +#' parse_df(iris[, 1:2], add_names = TRUE) +#' +#' # Use custom names +#' +#' parse_df(iris[, 1:2], add_names = c("x", "y")) #' parse_df <- function(data, add_names = FALSE) { data <- as.data.frame(data) diff --git a/cran-comments.md b/cran-comments.md index 6faa4d7..1a20305 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -7,9 +7,15 @@ 0 errors | 0 warnings | 1 note -* This is a new release. +* This is a re-submission. -An htmlwidget to create visualisations with the JavaScript library ApexCharts. +Re-submission to correct the problems identified in the first submission : + + * License MIT : only two lines + * Changed copyright holder in license to match Author field in description + * Updated the Description fiels, more than one sentence now + * Added a link to the JavaScript library in Description field + * All functions should have a value tag in documentation. Thank you! diff --git a/inst/htmlwidgets/lib/LICENSE b/inst/htmlwidgets/lib/LICENSE new file mode 100644 index 0000000..18d02fa --- /dev/null +++ b/inst/htmlwidgets/lib/LICENSE @@ -0,0 +1,24 @@ +ApexCharts.js +============= + +The MIT License (MIT) + +Copyright (c) 2018 ApexCharts + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/man/apex.Rd b/man/apex.Rd index 9648ad2..2ac1853 100644 --- a/man/apex.Rd +++ b/man/apex.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/apex.R \name{apex} \alias{apex} -\title{Quick Apex Chart} +\title{Quick ApexChart} \usage{ apex(data, mapping, type = "column", ..., auto_update = TRUE, width = NULL, height = NULL, elementId = NULL) @@ -25,8 +25,11 @@ apex(data, mapping, type = "column", ..., auto_update = TRUE, \item{elementId}{Use an explicit element ID for the widget.} } +\value{ +A \code{apexcharts} \code{htmlwidget} object. +} \description{ -Quick Apex Chart +Initialize a chart with three main parameters : data, mapping and type of chart. } \examples{ library(dplyr) diff --git a/man/apexcharter-shiny.Rd b/man/apexcharter-shiny.Rd index e4f4bb5..d219eb6 100644 --- a/man/apexcharter-shiny.Rd +++ b/man/apexcharter-shiny.Rd @@ -24,6 +24,9 @@ string and have \code{'px'} appended.} \item{quoted}{Is \code{expr} a quoted expression (with \code{quote()})? This is useful if you want to save an expression in a variable.} } +\value{ +An Apexchart output that can be included in the application UI. +} \description{ Output and render functions for using apexcharter within Shiny applications and interactive Rmd documents. diff --git a/man/bar_opts.Rd b/man/bar_opts.Rd index 2a6d772..7233b63 100644 --- a/man/bar_opts.Rd +++ b/man/bar_opts.Rd @@ -25,6 +25,9 @@ bar_opts(horizontal = NULL, endingShape = NULL, columnWidth = NULL, \item{...}{Additional parameters.} } +\value{ +A \code{list} of options that can be used in \code{\link{ax_plotOptions}}. +} \description{ Use these options in \code{\link{ax_plotOptions}}. } diff --git a/man/events_opts.Rd b/man/events_opts.Rd index 0243613..a5913e1 100644 --- a/man/events_opts.Rd +++ b/man/events_opts.Rd @@ -37,6 +37,9 @@ events_opts(click = NULL, beforeMount = NULL, mounted = NULL, \item{...}{Additional parameters.} } +\value{ +A \code{list} of options that can be used in \code{\link{ax_chart}}. +} \description{ Events options } @@ -45,3 +48,52 @@ All arguments should be JavaScript function defined with \code{htmlwidgets::JS}. See \url{https://apexcharts.com/docs/options/chart/events/}. } +\examples{ + +if (interactive()) { + library(shiny) + + ui <- fluidPage( + fluidRow( + column( + width = 8, offset = 2, + tags$h2("Apexchart in Shiny"), + apexchartOutput("chart"), + verbatimTextOutput(outputId = "res_click") + ) + ) + ) + + server <- function(input, output, session) { + + output$chart <- renderApexchart({ + apexchart() \%>\% + ax_chart( + type = "bar", + events = events_opts( + dataPointSelection = JS( + "function(event, chartContext, config) { + Shiny.setInputValue('click', config.selectedDataPoints) + }" + ) + ) + ) \%>\% + ax_series( + list( + name = "Example", + data = sample(1:100, 5) + ) + ) \%>\% + ax_xaxis( + categories = LETTERS[1:5] + ) + }) + + output$res_click <- renderPrint({ + input$click + }) + } + + shinyApp(ui, server) +} +} diff --git a/man/heatmap_opts.Rd b/man/heatmap_opts.Rd index 50d7dce..67cd370 100644 --- a/man/heatmap_opts.Rd +++ b/man/heatmap_opts.Rd @@ -18,6 +18,9 @@ heatmap_opts(radius = NULL, enableShades = NULL, \item{...}{Additional parameters.} } +\value{ +A \code{list} of options that can be used in \code{\link{ax_plotOptions}}. +} \description{ Use these options in \code{\link{ax_plotOptions}}. } diff --git a/man/parse_df.Rd b/man/parse_df.Rd index 0938f50..d0b85d3 100644 --- a/man/parse_df.Rd +++ b/man/parse_df.Rd @@ -12,6 +12,22 @@ parse_df(data, add_names = FALSE) \item{add_names}{Use names of columns in output. Can be logical to reuse \code{data} names or a character vector of new names.} } +\value{ +A \code{list} that can be used to specify data in \code{\link{ax_series}} for example. +} \description{ Convert data to a format suitable for ApexCharts.js } +\examples{ + +# All iris dataset +parse_df(iris) + +# Keep variables names +parse_df(iris[, 1:2], add_names = TRUE) + +# Use custom names + +parse_df(iris[, 1:2], add_names = c("x", "y")) + +} diff --git a/man/pie_opts.Rd b/man/pie_opts.Rd index 9a55510..cf836e6 100644 --- a/man/pie_opts.Rd +++ b/man/pie_opts.Rd @@ -23,6 +23,9 @@ and \code{background} (The background color of the pie).} \item{...}{Additional parameters.} } +\value{ +A \code{list} of options that can be used in \code{\link{ax_plotOptions}}. +} \description{ Use these options in \code{\link{ax_plotOptions}}. } diff --git a/man/radialBar_opts.Rd b/man/radialBar_opts.Rd index 15341da..528c923 100644 --- a/man/radialBar_opts.Rd +++ b/man/radialBar_opts.Rd @@ -29,6 +29,9 @@ radialBar_opts(size = NULL, inverseOrder = NULL, startAngle = NULL, \item{...}{Additional parameters.} } +\value{ +A \code{list} of options that can be used in \code{\link{ax_plotOptions}}. +} \description{ Use these options in \code{\link{ax_plotOptions}}. }