rstudio / dygraphs

R interface to dygraphs
http://rstudio.github.io/dygraphs
Other
365 stars 194 forks source link

More advanced plots are not showing #237

Open Ljupch0 opened 4 years ago

Ljupch0 commented 4 years ago

When I plot basic graphs there aren't any issues, however when I try to plot something like dyBarSeries(), it plots the points on the graph and shows them when I pass with the cursor, however no barplots are generated.

Here is a reproducible example taken straight from the dygraphs for R github pages:

lungDeaths <- cbind(mdeaths, fdeaths)
dygraph(lungDeaths) %>%
  dyRangeSelector() %>%
  dyBarSeries('fdeaths') %>% 
  dyFilledLine('mdeaths')

I am supposed to get this: image

but instead I get this: image

What can be causing this? I also tried rstudio.cloud to check whether it was my R installation and packages, and I got the same bad results.

Huh commented 4 years ago

I realized similar behavior after upgrading to htmlwidgets 1.5.1, potentially related to htmlwidgets 349. Basically the plot is built, mouseover has desired effect, but bars fail to appear. In fact, most of the examples on the Plotters page of the dygraphs website fail to produce expected plot.

reprex

library(dygraphs)
lungDeaths <- cbind(mdeaths, fdeaths)

dygraph(
    lungDeaths
  ) %>%
  dyStackedBarGroup(
    name = colnames(lungDeaths)
  )

# Similar behavior
dygraph(lungDeaths) %>%
  dyBarSeries('fdeaths') %>% 
  dyFilledLine('mdeaths')

# Try just the dyBarSeries and a line is produced
dygraph(lungDeaths) %>%
  dyRangeSelector() %>%
  dyBarSeries('fdeaths')

Result of sessionInfo() from Windows below, but behavior reproducible on Centos7 machine.

R version 3.6.0 (2019-04-26)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17763)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

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

other attached packages:
 [1] dplyr_0.8.3             lubridate_1.7.4         tidyr_1.0.0             purrr_0.3.3            
 [5] readr_1.3.1             httr_1.4.0              rlang_0.4.1             gmailr_0.7.1           
 [9] echarts4r_0.2.3         plotly_4.9.0            dygraphs_1.1.1.6        rbokeh_0.5.0           
[13] rhandsontable_0.3.7     extrafont_0.17          hrbrthemes_0.6.0        prettyreport_0.0.0.9000
[17] sp_1.3-1                leaflet_2.0.2           DT_0.10                 knitr_1.23             
[21] rmarkdown_1.14          rjags_4-8               coda_0.19-2             shinydashboard_0.7.1   
[25] ggplot2_3.2.1           shiny_1.3.2             testthat_2.3.0          usethis_1.5.0          
[29] devtools_2.0.2         

loaded via a namespace (and not attached):
 [1] fs_1.3.1           xts_0.11-2         rprojroot_1.3-2    tools_3.6.0        backports_1.1.5    rgdal_1.4-4       
 [7] R6_2.4.0           rgeos_0.4-3        lazyeval_0.2.2     colorspace_1.4-1   withr_2.1.2        tidyselect_0.2.5  
[13] prettyunits_1.0.2  processx_3.4.1     compiler_3.6.0     extrafontdb_1.0    cli_1.1.0          desc_1.2.0        
[19] scales_1.0.0       hexbin_1.27.3      callr_3.3.2        stringr_1.4.0      digest_0.6.22      base64enc_0.1-3   
[25] pkgconfig_2.0.3    htmltools_0.4.0    sessioninfo_1.1.1  highr_0.8          maps_3.3.0         htmlwidgets_1.5.1 
[31] rstudioapi_0.10    gistr_0.4.2        pryr_0.1.4         zoo_1.8-6          jsonlite_1.6       crosstalk_1.0.0   
[37] magrittr_1.5       Rcpp_1.0.2         munsell_0.5.0      gdtools_0.1.9      lifecycle_0.1.0    yaml_2.2.0        
[43] stringi_1.4.3      pkgbuild_1.0.6     grid_3.6.0         promises_1.0.1     crayon_1.3.4       lattice_0.20-38   
[49] hms_0.4.2          zeallot_0.1.0      ps_1.3.0           pillar_1.4.2       codetools_0.2-16   pkgload_1.0.2     
[55] glue_1.3.1         evaluate_0.14      data.table_1.12.2  remotes_2.0.4      vctrs_0.2.0        httpuv_1.5.1      
[61] Rttf2pt1_1.3.7     gtable_0.3.0       assertthat_0.2.1   xfun_0.6           mime_0.7           xtable_1.8-4      
[67] later_0.8.0        viridisLite_0.3.0  tibble_2.1.3       memoise_1.1.0.9000 ellipsis_0.3.0 
cpelat commented 4 years ago

Hi, I had the same issue : when using dygraphs 1.1.1.6 with htmlwidgets 1.5.1 and R 3.6.2 under Windows, the dyBarSeries() and dyFilledLine() plotters did not show on the dygraph.

Below is a reproducible example and the session info

library( dygraphs )
library( dplyr )

lungDeaths <- cbind(mdeaths, fdeaths)
dygraph(lungDeaths) %>%
  dyRangeSelector() %>%
  dyBarSeries('fdeaths') %>% 
  dyFilledLine('mdeaths')

 sessionInfo()
R version 3.6.2 (2019-12-12)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

Matrix products: default

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

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

other attached packages:
[1] dplyr_0.8.3      dygraphs_1.1.1.6

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.3        lattice_0.20-38   zoo_1.8-6         crayon_1.3.4      packrat_0.5.0     digest_0.6.23     assertthat_0.2.1  grid_3.6.2       
 [9] R6_2.4.1          magrittr_1.5      pillar_1.4.3      rlang_0.4.2       rstudioapi_0.10   tools_3.6.2       glue_1.3.1        htmlwidgets_1.5.1
[17] purrr_0.3.3       compiler_3.6.2    pkgconfig_2.0.3   htmltools_0.4.0   tidyselect_0.2.5  tibble_2.1.3     

Resulting plot : image

The javascript console indicates an error :

Uncaught TypeError: y is not a function at t.renderLineChart (dygraph-combined.js:2) at t.render (dygraph-combined.js:2) at t.renderGraph (dygraph-combined.js:3) at t.drawGraph (dygraph-combined.js:3) at t.predraw (dygraph-combined.js:3) at t.start_ (dygraph-combined.js:3) at t.init (dygraph-combined.js:2) at new t (dygraph-combined.js:2) at Object.renderValue (dygraphs.js:231) at Object.renderValue (htmlwidgets.js:886)

I discovered that htmlwidgets 1.5 had been upgraded to jQuery 3 while dygraphs 1.1.1.6 had not and got the dyplotters work by downgrading htmlwidgets to version 1.3.

`htmlwidgets 1.5

Yet this solution is only temporary as I suppose more dependencies will upgrade to jQuery 3. Is it planned to upgrade the dygraphs package code to jQuery 3?

Thanks a lot for your answer. Camille

timelyportfolio commented 4 years ago

I am experiencing the same issue. I will see if I can find a solution.

timelyportfolio commented 4 years ago

@cpelat see https://github.com/ramnathv/htmlwidgets/issues/356

cpelat commented 4 years ago

Thanks @timelyportfolio for the info !