added set_tooltip_fixed()

This commit is contained in:
pvictor 2020-04-04 18:38:12 +02:00
parent 8d751a485e
commit 79f04f26da
4 changed files with 76 additions and 0 deletions

View File

@ -54,6 +54,7 @@ export(run_input_demo)
export(set_input_click)
export(set_input_selection)
export(set_input_zoom)
export(set_tooltip_fixed)
importFrom(ggplot2,aes)
importFrom(htmlwidgets,JS)
importFrom(htmlwidgets,createWidget)

23
R/tooltip.R Normal file
View File

@ -0,0 +1,23 @@
#' Fix tooltip
#'
#' @param ax An \code{apexcharts} \code{htmlwidget} object.
#' @param position Predefined position: \code{"topLeft"}, \code{"topRight"},
#' \code{"bottomLeft"} or \code{"bottomRight"}.
#' @param offsetX Sets the left offset for the tooltip container in fixed position.
#' @param offsetY Sets the top offset for the tooltip container in fixed position.
#'
#' @return An \code{apexcharts} \code{htmlwidget} object.
#' @export
#'
#' @example examples/set_tooltip_fixed.R
set_tooltip_fixed <- function(ax,
position = c("topLeft", "topRight", "bottomLeft", "bottomRight"),
offsetX = NULL,
offsetY = NULL) {
position <- match.arg(position)
ax_tooltip(ax = ax, fixed = list(
enabled = TRUE, position = position,
offsetX = offsetX, offsetY = offsetY
))
}

View File

@ -0,0 +1,10 @@
library(apexcharter)
data("economics", package = "ggplot2")
apex(
data = tail(economics, 350),
mapping = aes(x = date, y = uempmed),
type = "line"
) %>%
set_tooltip_fixed()

42
man/set_tooltip_fixed.Rd Normal file
View File

@ -0,0 +1,42 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/tooltip.R
\name{set_tooltip_fixed}
\alias{set_tooltip_fixed}
\title{Fix tooltip}
\usage{
set_tooltip_fixed(
ax,
position = c("topLeft", "topRight", "bottomLeft", "bottomRight"),
offsetX = NULL,
offsetY = NULL
)
}
\arguments{
\item{ax}{An \code{apexcharts} \code{htmlwidget} object.}
\item{position}{Predefined position: \code{"topLeft"}, \code{"topRight"},
\code{"bottomLeft"} or \code{"bottomRight"}.}
\item{offsetX}{Sets the left offset for the tooltip container in fixed position.}
\item{offsetY}{Sets the top offset for the tooltip container in fixed position.}
}
\value{
An \code{apexcharts} \code{htmlwidget} object.
}
\description{
Fix tooltip
}
\examples{
library(apexcharter)
data("economics", package = "ggplot2")
apex(
data = tail(economics, 350),
mapping = aes(x = date, y = uempmed),
type = "line"
) \%>\%
set_tooltip_fixed()
}