Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,8 @@ try_file <- function(f, what) {
# preferred defaults for toJSON mapping
to_JSON <- function(x, ...) {
jsonlite::toJSON(x, digits = 50, auto_unbox = TRUE, force = TRUE,
null = "null", na = "null", ...)
null = "null", na = "null",
time_format = "%Y-%m-%d %H:%M:%OS6", ...)
}

# preferred defaults for toJSON mapping
Expand Down
1 change: 1 addition & 0 deletions tests/figs/lines/line-milliseconds.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 13 additions & 1 deletion tests/testthat/test-ggplot-lines.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,19 @@ test_that("different colored lines become different colored traces", {
expect_identical(info$data[[2]]$x[1:n], x)
})


test_that("Milliseconds are preserved with dynamic ticks", {
d <- data.frame(
t = as.POSIXct("1970-01-01 00:00") + (0:999) / 10,
y = sin((0:999) * 4 * pi / 1000)
)
gg <- ggplot(d, aes(t, y)) + geom_line()
p <- ggplotly(gg, dynamicTicks = TRUE)
j <- plotly_json(p, jsonedit = FALSE)
t2 <- jsonlite::fromJSON(j)$data$x[[1]] %>%
as.POSIXct(format = "%Y-%m-%d %H:%M:%OS")
expect_equal(as.numeric(mean(diff(t2))), 0.1)
expect_doppelganger_built(p, "line-milliseconds")
})

test_that("Translates both dates and datetimes (with dynamic ticks) correctly", {

Expand Down