From 660e795cf8fb38f852616a84d3436cdaa743fefb Mon Sep 17 00:00:00 2001 From: pvictor Date: Fri, 3 Aug 2018 11:10:36 +0200 Subject: [PATCH] added some options --- NAMESPACE | 7 ++ R/apex-options.R | 270 +++++++++++++++++------------------------- R/apex-utils.R | 8 +- README.md | 2 +- man/ax_plotOptions.Rd | 8 +- man/barOpts.Rd | 33 ++++++ man/eventsOpts.Rd | 35 ++++++ man/heatmapOpts.Rd | 26 ++++ man/pieOpts.Rd | 31 +++++ man/radialBarOpts.Rd | 37 ++++++ man/scrollerOpts.Rd | 32 +++++ man/selectionOpts.Rd | 29 +++++ 12 files changed, 349 insertions(+), 169 deletions(-) create mode 100644 man/barOpts.Rd create mode 100644 man/eventsOpts.Rd create mode 100644 man/heatmapOpts.Rd create mode 100644 man/pieOpts.Rd create mode 100644 man/radialBarOpts.Rd create mode 100644 man/scrollerOpts.Rd create mode 100644 man/selectionOpts.Rd diff --git a/NAMESPACE b/NAMESPACE index dccde9e..eb3446d 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -23,7 +23,14 @@ export(ax_title) export(ax_tooltip) export(ax_xaxis) export(ax_yaxis) +export(barOpts) +export(eventsOpts) +export(heatmapOpts) +export(pieOpts) +export(radialBarOpts) export(renderApexcharter) +export(scrollerOpts) +export(selectionOpts) importFrom(htmlwidgets,createWidget) importFrom(htmlwidgets,shinyRenderWidget) importFrom(htmlwidgets,shinyWidgetOutput) diff --git a/R/apex-options.R b/R/apex-options.R index bf9a5e7..43ffa41 100644 --- a/R/apex-options.R +++ b/R/apex-options.R @@ -6,6 +6,20 @@ +#' Options for scroller +#' +#' @param enabled +#' @param height +#' @param track +#' @param thumb +#' @param scrollButtons +#' @param padding +#' @param offsetX +#' @param offsetY +#' @param ... +#' +#' @export +#' scrollerOpts <- function(enabled = NULL, height = NULL, track = NULL, @@ -31,6 +45,22 @@ scrollerOpts <- function(enabled = NULL, } +#' Events options +#' +#' @param beforeMount JS function. Fires before the chart has been drawn on screen. +#' @param mounted JS function. Fires after the chart has been drawn on screen. +#' @param updated JS function. Fires when the chart has been dynamically updated either with updateOptions() or updateSeries() functions. +#' @param clicked JS function. Fires when user clicks on any area of the chart. +#' @param selection JS function. Fires when user selects rect using the selection tool. +#' @param dataPointSelection JS function. Fires when user clicks on a datapoint. +#' @param zoomed JS function. Fires when user zooms in/out the chart using either the selection zooming tool or zoom in/out buttons. +#' @param scrolled JS function. Fires when user scrolls using either the pan tool or scroller. +#' @param ... Additional parameters. +#' +#' @note See \url{https://apexcharts.com/docs/options/chart/events/}. +#' +#' @export +#' eventsOpts <- function(beforeMount = NULL, mounted = NULL, updated = NULL, @@ -56,6 +86,19 @@ eventsOpts <- function(beforeMount = NULL, } +#' Selection options +#' +#' @param enabled +#' @param type +#' @param selectedPoints +#' @param fill +#' @param stroke +#' @param xaxis +#' @param yaxis +#' @param ... +#' +#' @export +#' selectionOpts <- function(enabled = NULL, type = NULL, selectedPoints = NULL, @@ -79,6 +122,23 @@ selectionOpts <- function(enabled = NULL, } +#' Bar options +#' +#' Use these options in \code{\link{ax_plotOptions}}. +#' +#' @param horizontal Logical. This option will turn a column chart into a horiontal bar chart. +#' @param endingShape Available Options: \code{"flat"}, \code{"rounded"} or \code{"arrow"}. +#' @param columnWidth In column charts, columnWidth is the percentage of the available width in the grid-rect. +#' @param barHeight In horizontal bar charts, barHeight is the percentage of the available height in the grid-rect. +#' @param distributed Logical. Turn this option to make the bars discrete. Each value indicates one bar per series. +#' @param colors List. +#' @param dataLabels List with fields \code{position} (available options: \code{"top"}, \code{"center"} or \code{"bottom"}) +#' @param ... Additional parameters. +#' +#' @note See \url{https://apexcharts.com/docs/options/plotoptions/bar/}. +#' +#' @export +#' barOpts <- function(horizontal = NULL, endingShape = NULL, columnWidth = NULL, @@ -102,6 +162,20 @@ barOpts <- function(horizontal = NULL, } +#' Heatmap options +#' +#' 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 +#' @param shadeIntensity Numeric \code{[0,1]}. The intensity of the shades generated for each value. +#' @param colorScale List. +#' @param ... Additional parameters. +#' +#' @note See \url{https://apexcharts.com/docs/options/plotoptions/heatmap/}. +#' +#' @export +#' heatmapOpts <- function(radius = NULL, enableShades = NULL, shadeIntensity = NULL, @@ -119,6 +193,25 @@ heatmapOpts <- function(radius = NULL, } +#' Radial bar options +#' +#' 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. +#' @param startAngle Numeric. Angle from which the radialBars should start. +#' @param endAngle Numeric. Angle to which the radialBars should end. The sum of the startAngle and endAngle should not exceed 360. +#' @param offsetX Numeric. Sets the left offset for radialBars. +#' @param offsetY Numeric. Sets the top offset for radialBars. +#' @param hollow List. +#' @param track List. +#' @param dataLabels List. +#' @param ... Additional parameters. +#' +#' @note See \url{https://apexcharts.com/docs/options/plotoptions/radialbar/}. +#' +#' @export +#' radialBarOpts <- function(size = NULL, inverseOrder = NULL, startAngle = NULL, @@ -146,6 +239,23 @@ radialBarOpts <- function(size = NULL, } +#' Pie options +#' +#' 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{donutSize} (Donut / ring size in percentage relative to the total pie area.) +#' and \code{background} (The background color of the pie). +#' @param customScale Numeric. Transform the scale of whole pie/donut overriding the default calculations. +#' @param offsetX Numeric. Sets the left offset of the whole pie area. +#' @param offsetY Numeric. Sets the top offset of the whole pie area. +#' @param dataLabels List with field \code{offset} (Numeric, Offset by which labels will move outside / inside of the donut area) +#' @param ... Additional parameters. +#' +#' @note See \url{https://apexcharts.com/docs/options/plotoptions/pie/}. +#' +#' @export +#' pieOpts <- function(size = NULL, donut = NULL, customScale = NULL, @@ -166,163 +276,3 @@ pieOpts <- function(size = NULL, ) } - -scrollerOpts <- function(enabled = NULL, - height = NULL, - track = NULL, - thumb = NULL, - scrollButtons = NULL, - padding = NULL, - offsetX = NULL, - offsetY = NULL, - ...) { - dropNulls(c( - list( - enabled = enabled, - height = height, - track = track, - thumb = thumb, - scrollButtons = scrollButtons, - padding = padding, - offsetX = offsetX, - offsetY = offsetY - ), - list(...) - )) -} - - -eventsOpts <- function(beforeMount = NULL, - mounted = NULL, - updated = NULL, - clicked = NULL, - selection = NULL, - dataPointSelection = NULL, - zoomed = NULL, - scrolled = NULL, - ...) { - dropNulls(c( - list( - beforeMount = beforeMount, - mounted = mounted, - updated = updated, - clicked = clicked, - selection = selection, - dataPointSelection = dataPointSelection, - zoomed = zoomed, - scrolled = scrolled - ), - list(...) - )) -} - - -selectionOpts <- function(enabled = NULL, - type = NULL, - selectedPoints = NULL, - fill = NULL, - stroke = NULL, - xaxis = NULL, - yaxis = NULL, - ...) { - dropNulls(c( - list( - enabled = enabled, - type = type, - selectedPoints = selectedPoints, - fill = fill, - stroke = stroke, - xaxis = xaxis, - yaxis = yaxis - ), - list(...) - )) -} - - -barOpts <- function(horizontal = NULL, - endingShape = NULL, - columnWidth = NULL, - barHeight = NULL, - distributed = NULL, - colors = NULL, - dataLabels = NULL, - ...) { - dropNulls(c( - list( - horizontal = horizontal, - endingShape = endingShape, - columnWidth = columnWidth, - barHeight = barHeight, - distributed = distributed, - colors = colors, - dataLabels = dataLabels - ), - list(...) - )) -} - - -heatmapOpts <- function(radius = NULL, - enableShades = NULL, - shadeIntensity = NULL, - colorScale = NULL, - ...) { - dropNulls(c( - list( - radius = radius, - enableShades = enableShades, - shadeIntensity = shadeIntensity, - colorScale = colorScale - ), - list(...) - )) -} - - -radialBarOpts <- function(size = NULL, - inverseOrder = NULL, - startAngle = NULL, - endAngle = NULL, - offsetX = NULL, - offsetY = NULL, - hollow = NULL, - track = NULL, - dataLabels = NULL, - ...) { - dropNulls(c( - list( - size = size, - inverseOrder = inverseOrder, - startAngle = startAngle, - endAngle = endAngle, - offsetX = offsetX, - offsetY = offsetY, - hollow = hollow, - track = track, - dataLabels = dataLabels - ), - list(...) - )) -} - - -pieOpts <- function(size = NULL, - donut = NULL, - customScale = NULL, - offsetX = NULL, - offsetY = NULL, - dataLabels = NULL, - ...) { - dropNulls(c( - list( - size = size, - donut = donut, - customScale = customScale, - offsetX = offsetX, - offsetY = offsetY, - dataLabels = dataLabels - ), - list(...) - )) -} diff --git a/R/apex-utils.R b/R/apex-utils.R index a21f02f..53e645a 100644 --- a/R/apex-utils.R +++ b/R/apex-utils.R @@ -86,10 +86,10 @@ ax_chart <- function(ax, #' Specific options for chart #' #' @param ax A \code{apexcharts} \code{htmlwidget} object. -#' @param bar -#' @param heatmap -#' @param radialBar -#' @param pie +#' @param bar See \code{\link{barOpts}}. +#' @param heatmap See \code{\link{heatmapOpts}}. +#' @param radialBar See \code{\link{radialBarOpts}}. +#' @param pie See \code{\link{pieOpts}}. #' @param ... Additional parameters. #' #' @return A \code{apexcharts} \code{htmlwidget} object. diff --git a/README.md b/README.md index 9d8671e..12ed4d9 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ dat <- count(mpg, manufacturer) apexcharter() %>% ax_chart(type = "bar") %>% - ax_plotOptions(bar = list( + ax_plotOptions(bar = barOpts( horizontal = FALSE, endingShape = "flat", columnWidth = "70%", diff --git a/man/ax_plotOptions.Rd b/man/ax_plotOptions.Rd index 6240bb6..7e70bbf 100644 --- a/man/ax_plotOptions.Rd +++ b/man/ax_plotOptions.Rd @@ -10,13 +10,13 @@ ax_plotOptions(ax, bar = NULL, heatmap = NULL, radialBar = NULL, \arguments{ \item{ax}{A \code{apexcharts} \code{htmlwidget} object.} -\item{bar}{} +\item{bar}{See \code{\link{barOpts}}.} -\item{heatmap}{} +\item{heatmap}{See \code{\link{heatmapOpts}}.} -\item{radialBar}{} +\item{radialBar}{See \code{\link{radialBarOpts}}.} -\item{pie}{} +\item{pie}{See \code{\link{pieOpts}}.} \item{...}{Additional parameters.} } diff --git a/man/barOpts.Rd b/man/barOpts.Rd new file mode 100644 index 0000000..e2323e3 --- /dev/null +++ b/man/barOpts.Rd @@ -0,0 +1,33 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/apex-options.R +\name{barOpts} +\alias{barOpts} +\title{Bar options} +\usage{ +barOpts(horizontal = NULL, endingShape = NULL, columnWidth = NULL, + barHeight = NULL, distributed = NULL, colors = NULL, + dataLabels = NULL, ...) +} +\arguments{ +\item{horizontal}{Logical. This option will turn a column chart into a horiontal bar chart.} + +\item{endingShape}{Available Options: \code{"flat"}, \code{"rounded"} or \code{"arrow"}.} + +\item{columnWidth}{In column charts, columnWidth is the percentage of the available width in the grid-rect.} + +\item{barHeight}{In horizontal bar charts, barHeight is the percentage of the available height in the grid-rect.} + +\item{distributed}{Logical. Turn this option to make the bars discrete. Each value indicates one bar per series.} + +\item{colors}{List.} + +\item{dataLabels}{List with fields \code{position} (available options: \code{"top"}, \code{"center"} or \code{"bottom"})} + +\item{...}{Additional parameters.} +} +\description{ +Use these options in \code{\link{ax_plotOptions}}. +} +\note{ +See \url{https://apexcharts.com/docs/options/plotoptions/bar/}. +} diff --git a/man/eventsOpts.Rd b/man/eventsOpts.Rd new file mode 100644 index 0000000..c780b89 --- /dev/null +++ b/man/eventsOpts.Rd @@ -0,0 +1,35 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/apex-options.R +\name{eventsOpts} +\alias{eventsOpts} +\title{Events options} +\usage{ +eventsOpts(beforeMount = NULL, mounted = NULL, updated = NULL, + clicked = NULL, selection = NULL, dataPointSelection = NULL, + zoomed = NULL, scrolled = NULL, ...) +} +\arguments{ +\item{beforeMount}{JS function. Fires before the chart has been drawn on screen.} + +\item{mounted}{JS function. Fires after the chart has been drawn on screen.} + +\item{updated}{JS function. Fires when the chart has been dynamically updated either with updateOptions() or updateSeries() functions.} + +\item{clicked}{JS function. Fires when user clicks on any area of the chart.} + +\item{selection}{JS function. Fires when user selects rect using the selection tool.} + +\item{dataPointSelection}{JS function. Fires when user clicks on a datapoint.} + +\item{zoomed}{JS function. Fires when user zooms in/out the chart using either the selection zooming tool or zoom in/out buttons.} + +\item{scrolled}{JS function. Fires when user scrolls using either the pan tool or scroller.} + +\item{...}{Additional parameters.} +} +\description{ +Events options +} +\note{ +See \url{https://apexcharts.com/docs/options/chart/events/}. +} diff --git a/man/heatmapOpts.Rd b/man/heatmapOpts.Rd new file mode 100644 index 0000000..061294e --- /dev/null +++ b/man/heatmapOpts.Rd @@ -0,0 +1,26 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/apex-options.R +\name{heatmapOpts} +\alias{heatmapOpts} +\title{Heatmap options} +\usage{ +heatmapOpts(radius = NULL, enableShades = NULL, shadeIntensity = NULL, + colorScale = NULL, ...) +} +\arguments{ +\item{radius}{Numeric. Radius of the rectangle inside heatmap.} + +\item{enableShades}{Logical. Enable different shades of color depending on the value} + +\item{shadeIntensity}{Numeric \code{[0,1]}. The intensity of the shades generated for each value.} + +\item{colorScale}{List.} + +\item{...}{Additional parameters.} +} +\description{ +Use these options in \code{\link{ax_plotOptions}}. +} +\note{ +See \url{https://apexcharts.com/docs/options/plotoptions/heatmap/}. +} diff --git a/man/pieOpts.Rd b/man/pieOpts.Rd new file mode 100644 index 0000000..48a3025 --- /dev/null +++ b/man/pieOpts.Rd @@ -0,0 +1,31 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/apex-options.R +\name{pieOpts} +\alias{pieOpts} +\title{Pie options} +\usage{ +pieOpts(size = NULL, donut = NULL, customScale = NULL, offsetX = NULL, + offsetY = NULL, dataLabels = NULL, ...) +} +\arguments{ +\item{size}{Numeric. Custom size of the pie which will override the default size calculations.} + +\item{donut}{List with two fields \code{donutSize} (Donut / ring size in percentage relative to the total pie area.) +and \code{background} (The background color of the pie).} + +\item{customScale}{Numeric. Transform the scale of whole pie/donut overriding the default calculations.} + +\item{offsetX}{Numeric. Sets the left offset of the whole pie area.} + +\item{offsetY}{Numeric. Sets the top offset of the whole pie area.} + +\item{dataLabels}{List with field \code{offset} (Numeric, Offset by which labels will move outside / inside of the donut area)} + +\item{...}{Additional parameters.} +} +\description{ +Use these options in \code{\link{ax_plotOptions}}. +} +\note{ +See \url{https://apexcharts.com/docs/options/plotoptions/pie/}. +} diff --git a/man/radialBarOpts.Rd b/man/radialBarOpts.Rd new file mode 100644 index 0000000..7df0477 --- /dev/null +++ b/man/radialBarOpts.Rd @@ -0,0 +1,37 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/apex-options.R +\name{radialBarOpts} +\alias{radialBarOpts} +\title{Radial bar options} +\usage{ +radialBarOpts(size = NULL, inverseOrder = NULL, startAngle = NULL, + endAngle = NULL, offsetX = NULL, offsetY = NULL, hollow = NULL, + track = NULL, dataLabels = NULL, ...) +} +\arguments{ +\item{size}{Numeric. Manual size of the radialBars instead of calculating automatically from default height / width.} + +\item{inverseOrder}{Logical. Whether to make the first value of series innermost or outermost.} + +\item{startAngle}{Numeric. Angle from which the radialBars should start.} + +\item{endAngle}{Numeric. Angle to which the radialBars should end. The sum of the startAngle and endAngle should not exceed 360.} + +\item{offsetX}{Numeric. Sets the left offset for radialBars.} + +\item{offsetY}{Numeric. Sets the top offset for radialBars.} + +\item{hollow}{List.} + +\item{track}{List.} + +\item{dataLabels}{List.} + +\item{...}{Additional parameters.} +} +\description{ +Use these options in \code{\link{ax_plotOptions}}. +} +\note{ +See \url{https://apexcharts.com/docs/options/plotoptions/radialbar/}. +} diff --git a/man/scrollerOpts.Rd b/man/scrollerOpts.Rd new file mode 100644 index 0000000..f387e2d --- /dev/null +++ b/man/scrollerOpts.Rd @@ -0,0 +1,32 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/apex-options.R +\name{scrollerOpts} +\alias{scrollerOpts} +\title{Options for scroller} +\usage{ +scrollerOpts(enabled = NULL, height = NULL, track = NULL, thumb = NULL, + scrollButtons = NULL, padding = NULL, offsetX = NULL, offsetY = NULL, + ...) +} +\arguments{ +\item{enabled}{} + +\item{height}{} + +\item{track}{} + +\item{thumb}{} + +\item{scrollButtons}{} + +\item{padding}{} + +\item{offsetX}{} + +\item{offsetY}{} + +\item{...}{} +} +\description{ +Options for scroller +} diff --git a/man/selectionOpts.Rd b/man/selectionOpts.Rd new file mode 100644 index 0000000..2de62b6 --- /dev/null +++ b/man/selectionOpts.Rd @@ -0,0 +1,29 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/apex-options.R +\name{selectionOpts} +\alias{selectionOpts} +\title{Selection options} +\usage{ +selectionOpts(enabled = NULL, type = NULL, selectedPoints = NULL, + fill = NULL, stroke = NULL, xaxis = NULL, yaxis = NULL, ...) +} +\arguments{ +\item{enabled}{} + +\item{type}{} + +\item{selectedPoints}{} + +\item{fill}{} + +\item{stroke}{} + +\item{xaxis}{} + +\item{yaxis}{} + +\item{...}{} +} +\description{ +Selection options +}