more docs

This commit is contained in:
pvictor 2018-08-01 23:02:29 +02:00
parent cd51e66336
commit ba93c07fa5
5 changed files with 96 additions and 38 deletions

View File

@ -9,11 +9,13 @@
#' Annotations properties
#'
#' @param ax A \code{apexcharts} \code{htmlwidget} object.
#' @param position
#' @param yaxis
#' @param xaxis
#' @param points
#' @param position Whether to put the annotations behind the charts or in front of it. Available Options: \code{"front"} or \code{"back"}.
#' @param yaxis List of lists.
#' @param xaxis List of lists.
#' @param points List of lists.
#' @param ... Additional parameters.
#'
#' @note See \url{https://apexcharts.com/docs/options/annotations/}.
#'
#' @return A \code{apexcharts} \code{htmlwidget} object.
#' @export
@ -280,18 +282,17 @@ ax_legend <- function(ax,
#' Markers properties
#'
#' @param ax A \code{apexcharts} \code{htmlwidget} object.
#' @param discrete
#' @param size
#' @param colors
#' @param strokeColor
#' @param strokeWidth
#' @param strokeOpacity
#' @param fillOpacity
#' @param shape
#' @param radius
#' @param offsetX
#' @param offsetY
#' @param hover
#' @param size Numeric. Size of the marker point.
#' @param colors Sets the fill color(s) of the marker point.
#' @param strokeColor Stroke Color of the marker.
#' @param strokeWidth Stroke Size of the marker.
#' @param strokeOpacity Opacity of the border around marker.
#' @param fillOpacity Opacity of the marker fill color.
#' @param shape Shape of the marker. Available Options for shape: \code{"square"} or \code{"circle"}.
#' @param radius Numeric. Radius of the marker (applies to square shape)
#' @param offsetX Numeric. Sets the left offset of the marker.
#' @param offsetY Numeric. Sets the top offset of the marker.
#' @param hover List with item \code{size} (Size of the marker when it is active).
#' @param ... Additional parameters.
#'
#' @return A \code{apexcharts} \code{htmlwidget} object.
@ -299,7 +300,6 @@ ax_legend <- function(ax,
#'
#' @examples
ax_markers <- function(ax,
discrete = NULL,
size = NULL,
colors = NULL,
strokeColor = NULL,
@ -368,6 +368,26 @@ ax_responsive <- function(ax, ...) {
#' @export
#'
#' @examples
#'
#' # One serie
#' apexcharter() %>%
#' ax_series(list(
#' name = "rnorm",
#' data = rnorm(10)
#' ))
#'
#' # Two series
#' apexcharter() %>%
#' ax_series(
#' list(
#' name = "rnorm 1",
#' data = rnorm(10)
#' ),
#' list(
#' name = "rnorm 2",
#' data = rnorm(10)
#' )
#' )
ax_series <- function(ax, ...) {
.ax_opt(ax, "series", ...)
}

View File

@ -34,6 +34,27 @@ make_fun <- function(opts, name, file = "") {
return(invisible(res))
}
make_opts <- function(opts, name, file = "") {
args <- names(opts[[name]])
if (is.null(args)) {
args <- "..."
body <- "list(...)"
} else {
body <- sprintf("%s = %s", args, args)
body <- paste(body, collapse = ",\n")
body <- paste0("list(", body, ", ...)")
args <- sprintf("%s = NULL", args)
args <- paste(args, collapse = ",\n")
args <- paste0(args, ", ...")
}
body <- paste0("dropNulls(", body, ")")
res <- paste0(name, "Opts", " <- function(", args, ") {", body, "}\n\n\n")
cat(res, file = file, append = TRUE)
return(invisible(res))
}
# chart -------------------------------------------------------------------
@ -57,3 +78,16 @@ lapply(
# Options -----------------------------------------------------------------
# scroller
str(ApexOpts$chart$scroller)
make_opts(ApexOpts$chart, "scroller")
# plotOptions -- bar
make_opts(ApexOpts$plotOptions, "bar")

View File

@ -17,6 +17,9 @@ HTMLWidgets.widget({
ax_opts = x.ax_opts;
// Sizing
if (typeof ax_opts.chart === 'undefined') {
ax_opts.chart = {};
}
ax_opts.chart.width = width;
ax_opts.chart.height = height;

View File

@ -10,13 +10,13 @@ ax_annotations(ax, position = NULL, yaxis = NULL, xaxis = NULL,
\arguments{
\item{ax}{A \code{apexcharts} \code{htmlwidget} object.}
\item{position}{}
\item{position}{Whether to put the annotations behind the charts or in front of it. Available Options: \code{"front"} or \code{"back"}.}
\item{yaxis}{}
\item{yaxis}{List of lists.}
\item{xaxis}{}
\item{xaxis}{List of lists.}
\item{points}{}
\item{points}{List of lists.}
\item{...}{Additional parameters.}
}
@ -26,3 +26,6 @@ A \code{apexcharts} \code{htmlwidget} object.
\description{
Annotations properties
}
\note{
See \url{https://apexcharts.com/docs/options/annotations/}.
}

View File

@ -4,37 +4,35 @@
\alias{ax_markers}
\title{Markers properties}
\usage{
ax_markers(ax, discrete = NULL, size = NULL, colors = NULL,
strokeColor = NULL, strokeWidth = NULL, strokeOpacity = NULL,
fillOpacity = NULL, shape = NULL, radius = NULL, offsetX = NULL,
offsetY = NULL, hover = NULL, ...)
ax_markers(ax, size = NULL, colors = NULL, strokeColor = NULL,
strokeWidth = NULL, strokeOpacity = NULL, fillOpacity = NULL,
shape = NULL, radius = NULL, offsetX = NULL, offsetY = NULL,
hover = NULL, ...)
}
\arguments{
\item{ax}{A \code{apexcharts} \code{htmlwidget} object.}
\item{discrete}{}
\item{size}{Numeric. Size of the marker point.}
\item{size}{}
\item{colors}{Sets the fill color(s) of the marker point.}
\item{colors}{}
\item{strokeColor}{Stroke Color of the marker.}
\item{strokeColor}{}
\item{strokeWidth}{Stroke Size of the marker.}
\item{strokeWidth}{}
\item{strokeOpacity}{Opacity of the border around marker.}
\item{strokeOpacity}{}
\item{fillOpacity}{Opacity of the marker fill color.}
\item{fillOpacity}{}
\item{shape}{Shape of the marker. Available Options for shape: \code{"square"} or \code{"circle"}.}
\item{shape}{}
\item{radius}{Numeric. Radius of the marker (applies to square shape)}
\item{radius}{}
\item{offsetX}{Numeric. Sets the left offset of the marker.}
\item{offsetX}{}
\item{offsetY}{Numeric. Sets the top offset of the marker.}
\item{offsetY}{}
\item{hover}{}
\item{hover}{List with item \code{size} (Size of the marker when it is active).}
\item{...}{Additional parameters.}
}