2020-03-04 19:02:01 +01:00
|
|
|
|
|
|
|
#' @importFrom shiny registerInputHandler
|
2021-01-06 17:13:05 +01:00
|
|
|
.onLoad <- function(...) { # nocov start
|
2020-03-14 20:41:41 +01:00
|
|
|
shiny::registerInputHandler("apex_click", function(data, ...) {
|
|
|
|
if (is.null(data)) {
|
|
|
|
NULL
|
|
|
|
} else {
|
2020-03-17 18:05:41 +01:00
|
|
|
value <- ununlist(data$value)
|
|
|
|
if (isTRUE(data$datetime)) {
|
|
|
|
if (is.list(value)) {
|
|
|
|
value <- rapply(value, to_posix, how = "replace")
|
|
|
|
} else {
|
|
|
|
value <- to_posix(value)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return(value)
|
2020-03-14 20:41:41 +01:00
|
|
|
}
|
2020-12-02 15:50:03 +01:00
|
|
|
}, force = TRUE)
|
2020-03-04 19:02:01 +01:00
|
|
|
shiny::registerInputHandler("apex_datetime", function(data, ...) {
|
|
|
|
if (is.null(data)) {
|
|
|
|
NULL
|
|
|
|
} else {
|
|
|
|
result <- try({
|
|
|
|
data$x <- list(
|
|
|
|
min = to_posix(data$x$min),
|
|
|
|
max = to_posix(data$x$max)
|
|
|
|
)
|
|
|
|
data
|
|
|
|
}, silent = TRUE)
|
|
|
|
if (inherits(result, "try-error")) {
|
|
|
|
warning("apexcharter: Failed to parse dates!", call. = FALSE)
|
|
|
|
data
|
|
|
|
} else {
|
|
|
|
result
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, force = TRUE)
|
2020-12-03 11:03:59 +01:00
|
|
|
register_s3_method("knitr", "knit_print", "apex_facet")
|
2021-01-04 12:02:48 +01:00
|
|
|
register_s3_method("knitr", "knit_print", "apex_grid")
|
2021-01-06 17:13:05 +01:00
|
|
|
} # nocov end
|