Skip to content

Commit f9fe789

Browse files
committed
support new timezone argument, fixes #743
1 parent 66dc1af commit f9fe789

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

R/layers2traces.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ layers2traces <- function(data, prestats_data, layout, p) {
4747
if (identical("group", unique(varName, aesName))) next
4848
# by default assume the values don't need any formatting
4949
forMat <- function(x) if (is.numeric(x)) round(x, 2) else x
50+
sc <- p$scales$get_scales(aesName)
5051
if (isTRUE(aesName %in% c("x", "y"))) {
51-
scaleName <- p$scales$get_scales(aesName)$scale_name
5252
# convert "milliseconds from the UNIX epoch" to a date/datetime
5353
# http://stackoverflow.com/questions/13456241/convert-unix-epoch-to-date-object-in-r
54-
if ("datetime" %in% scaleName) forMat <- function(x) as.POSIXct(x, origin = "1970-01-01")
54+
if ("datetime" %in% sc$scale_name) forMat <- function(x) as.POSIXct(x, origin = "1970-01-01", tz = sc$timezone)
5555
# convert "days from the UNIX epoch" to a date/datetime
56-
if ("date" %in% scaleName) forMat <- function(x) as.Date(as.POSIXct(x * 86400, origin = "1970-01-01"))
56+
if ("date" %in% sc$scale_name) forMat <- function(x) as.Date(as.POSIXct(x * 86400, origin = "1970-01-01", tz = sc$timezone))
5757
}
5858
# add a line break if hovertext already exists
5959
if ("hovertext" %in% names(x)) x$hovertext <- paste0(x$hovertext, "<br>")

0 commit comments

Comments
 (0)