2020-04-04 12:36:42 +02:00
|
|
|
% Generated by roxygen2: do not edit by hand
|
|
|
|
% Please edit documentation in R/annotations.R
|
2020-07-26 18:38:18 +02:00
|
|
|
\name{add-vh-lines}
|
|
|
|
\alias{add-vh-lines}
|
2020-04-04 12:36:42 +02:00
|
|
|
\alias{add_hline}
|
|
|
|
\alias{add_vline}
|
|
|
|
\title{Add horizontal or vertical line}
|
|
|
|
\usage{
|
|
|
|
add_hline(ax, value, color = "#000", dash = 0, label = NULL, ...)
|
|
|
|
|
|
|
|
add_vline(ax, value, color = "#000", dash = 0, label = NULL, ...)
|
|
|
|
}
|
|
|
|
\arguments{
|
2021-11-17 11:41:10 +01:00
|
|
|
\item{ax}{An \code{\link[=apexchart]{apexchart()}} \code{htmlwidget} object.}
|
2020-04-04 12:36:42 +02:00
|
|
|
|
|
|
|
\item{value}{Vector of position for the line(s).}
|
|
|
|
|
|
|
|
\item{color}{Color(s) of the line(s).}
|
|
|
|
|
|
|
|
\item{dash}{Creates dashes in borders of SVG path.
|
|
|
|
A higher number creates more space between dashes in the border.
|
|
|
|
Use \code{0} for plain line.}
|
|
|
|
|
|
|
|
\item{label}{Add a label to the shade, use a \code{character}
|
|
|
|
or see \code{\link{label}} for more controls.}
|
|
|
|
|
|
|
|
\item{...}{Additional arguments, see
|
|
|
|
\url{https://apexcharts.com/docs/options/annotations/} for possible options.}
|
|
|
|
}
|
|
|
|
\value{
|
2021-11-17 11:41:10 +01:00
|
|
|
An \code{\link[=apexchart]{apexchart()}} \code{htmlwidget} object.
|
2020-04-04 12:36:42 +02:00
|
|
|
}
|
|
|
|
\description{
|
|
|
|
Add horizontal or vertical line
|
|
|
|
}
|
|
|
|
\examples{
|
|
|
|
|
|
|
|
library(apexcharter)
|
|
|
|
|
|
|
|
# On a column chart
|
2021-11-29 20:04:50 +01:00
|
|
|
unhcr_ts \%>\%
|
|
|
|
subset(year == 2017 & population_type == "Asylum-seekers") \%>\%
|
|
|
|
apex(
|
|
|
|
aes(continent_origin, n),
|
|
|
|
"column"
|
|
|
|
) \%>\%
|
|
|
|
add_hline(value = 5e5)
|
2020-04-04 12:36:42 +02:00
|
|
|
|
|
|
|
|
|
|
|
# On a scatter chart
|
|
|
|
apex(
|
2021-11-29 20:04:50 +01:00
|
|
|
data = cars,
|
|
|
|
aes(speed, dist),
|
2020-04-04 12:36:42 +02:00
|
|
|
"scatter"
|
2021-11-29 20:04:50 +01:00
|
|
|
) \%>\%
|
|
|
|
add_hline(value = mean(cars$dist)) \%>\%
|
|
|
|
add_vline(value = mean(cars$speed))
|
2020-04-04 12:36:42 +02:00
|
|
|
|
|
|
|
# With labels
|
|
|
|
apex(
|
2021-11-29 20:04:50 +01:00
|
|
|
data = cars,
|
|
|
|
aes(speed, dist),
|
2020-04-04 12:36:42 +02:00
|
|
|
"scatter"
|
2021-11-29 20:04:50 +01:00
|
|
|
) \%>\%
|
2020-04-04 12:36:42 +02:00
|
|
|
add_hline(
|
2021-11-29 20:04:50 +01:00
|
|
|
value = mean(cars$dist),
|
|
|
|
label = "Mean of dist"
|
|
|
|
) \%>\%
|
2020-04-04 12:36:42 +02:00
|
|
|
add_vline(
|
2021-11-29 20:04:50 +01:00
|
|
|
value = mean(cars$speed),
|
|
|
|
label = label(
|
|
|
|
text = "Mean of speed",
|
|
|
|
borderColor = "red"
|
|
|
|
)
|
2020-04-04 12:36:42 +02:00
|
|
|
)
|
|
|
|
}
|