73 lines
1.5 KiB
R
73 lines
1.5 KiB
R
% Generated by roxygen2: do not edit by hand
|
|
% Please edit documentation in R/mixed-charts.R
|
|
\name{add_line}
|
|
\alias{add_line}
|
|
\title{Add a line to a chart}
|
|
\usage{
|
|
add_line(
|
|
ax,
|
|
mapping,
|
|
data = NULL,
|
|
type = c("line", "spline"),
|
|
serie_name = NULL
|
|
)
|
|
}
|
|
\arguments{
|
|
\item{ax}{An \code{\link{apex}} \code{htmlwidget} object.}
|
|
|
|
\item{mapping}{Default list of aesthetic mappings to use for chart.}
|
|
|
|
\item{data}{A \code{data.frame} to use to add a line, if \code{NULL} (default),
|
|
the \code{data.frame} provided in \code{apex()} will be used.}
|
|
|
|
\item{type}{Type of line.}
|
|
|
|
\item{serie_name}{Name for the serie displayed in tooltip and legend.}
|
|
}
|
|
\value{
|
|
A \code{apexcharts} \code{htmlwidget} object.
|
|
}
|
|
\description{
|
|
Add a line to a chart
|
|
}
|
|
\examples{
|
|
library(apexcharter)
|
|
|
|
|
|
# Bar ----
|
|
|
|
data("climate_paris")
|
|
|
|
# Add a line on a column's chart
|
|
apex(climate_paris, aes(month, precipitation), type = "column") \%>\%
|
|
add_line(aes(month, temperature))
|
|
|
|
# Add secondary axis
|
|
apex(climate_paris, aes(month, precipitation), type = "column") \%>\%
|
|
add_line(aes(month, temperature)) \%>\%
|
|
ax_yaxis(
|
|
title = list(text = "Precipitation (in mm)")
|
|
) \%>\%
|
|
ax_yaxis2(
|
|
opposite = TRUE,
|
|
decimalsInFloat = 0,
|
|
title = list(text = "Temperature (in degree celsius)")
|
|
) \%>\%
|
|
ax_dataLabels(
|
|
enabled = TRUE, enabledOnSeries = list(1)
|
|
)
|
|
|
|
|
|
|
|
# Scatter ----
|
|
|
|
# add smooth line on scatter plot
|
|
apex(cars, aes(speed, dist), type = "scatter") \%>\%
|
|
add_line(aes(x, y), data = lowess(cars), serie_name = "lowess")
|
|
|
|
|
|
|
|
|
|
|
|
}
|