added some options

This commit is contained in:
pvictor 2018-08-03 11:10:36 +02:00
parent fc2b6f9bc8
commit 660e795cf8
12 changed files with 349 additions and 169 deletions

View File

@ -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)

View File

@ -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(...)
))
}

View File

@ -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.

View File

@ -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%",

View File

@ -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.}
}

33
man/barOpts.Rd Normal file
View File

@ -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/}.
}

35
man/eventsOpts.Rd Normal file
View File

@ -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/}.
}

26
man/heatmapOpts.Rd Normal file
View File

@ -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/}.
}

31
man/pieOpts.Rd Normal file
View File

@ -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/}.
}

37
man/radialBarOpts.Rd Normal file
View File

@ -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/}.
}

32
man/scrollerOpts.Rd Normal file
View File

@ -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
}

29
man/selectionOpts.Rd Normal file
View File

@ -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
}