Skip to content

Date time tooltips show different times than axis #772

@zelite

Description

@zelite

Hi,

I'm using the ggplotly for the convenience of exploring plots produced with ggplot. I noticed that when having a datetime axis, the tooltip does not show the original date in data, but converts it to what seems to be the system time zone.

library(lubridate)
library(ggplot2)
library(plotly)

a <- seq(from=ymd_hms("2016.06.16 16:16:16"), by="mins", length.out=10)
# By default the dates were created in UTC, my system time is CEST
# [1] "2016-06-16 16:16:16 UTC" "2016-06-16 16:17:16 UTC" "2016-06-16 16:18:16 UTC" "2016-06-16 16:19:16 UTC"
# [5] "2016-06-16 16:20:16 UTC" "2016-06-16 16:21:16 UTC" "2016-06-16 16:22:16 UTC" "2016-06-16 16:23:16 UTC"
# [9] "2016-06-16 16:24:16 UTC" "2016-06-16 16:25:16 UTC"

b <- 1:10

my_df <- data.frame(a, b)

p <- ggplot(data=my_df, aes(x=a, y=b))+geom_point()

ggplotly(p)

This is the result:

image

You see that the tooltip does not match the axis. This makes the exploration very hard because the displayed dates don't match what is in the data. I expect the tooltip to show me what is in the dataframe without any automatic conversions.

My session info:

> sessionInfo()
R version 3.3.1 (2016-06-21)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=German_Germany.1252  LC_CTYPE=German_Germany.1252    LC_MONETARY=German_Germany.1252
[4] LC_NUMERIC=C                    LC_TIME=German_Germany.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] plotly_4.5.2    ggplot2_2.1.0   lubridate_1.6.0

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.7       magrittr_1.5      munsell_0.4.3     colorspace_1.2-6  viridisLite_0.1.3 R6_2.1.3         
 [7] stringr_1.1.0     httr_1.2.1        plyr_1.8.4        dplyr_0.5.0       tools_3.3.1       grid_3.3.1       
[13] gtable_0.2.0      DBI_0.5-1         htmltools_0.3.5   yaml_2.1.13       lazyeval_0.2.0    assertthat_0.1   
[19] digest_0.6.10     tibble_1.2        purrr_0.2.2       tidyr_0.6.0       base64enc_0.1-3   htmlwidgets_0.7  
[25] labeling_0.3      stringi_1.1.2     scales_0.4.0      jsonlite_1.1 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions