g2r
g2r copied to clipboard
interact_zoom() with interact_brush() not working?
I'm very excited for this package! It seems like a very elegant syntax and I see lots of potential. I tried extending one of the Shiny examples by adding a simple zoom capability along with a brush (thinking it would work similar to how shiny
lets you interact with ggplot2
plots). I thought I could use the brush to select a region and either use the mouse or double-click to zoom in to the region, but the plot dimensions stays the same. Perhaps I missed some parameters? Here's the simple app I tried:
library(g2r)
library(shiny)
ui <- fluidPage(
actionButton("hide", "hide"),
actionButton("show", "show"),
g2Output("chart")
)
server <- function(input, output) {
output$chart <- renderG2({
g2(cars, asp(speed, dist)) %>%
fig_point() %>%
fig_line() %>%
interact_brush() %>%
interact_zoom()
})
observeEvent(input$hide, {
g2Proxy("chart") %>%
conceal()
})
observeEvent(input$show, {
g2Proxy("chart") %>%
reveal()
})
}
shinyApp(ui, server)
Session info in case it helps:
> devtools::session_info()
─ Session info ───────────────────────────────────────────────────────────────────────────────────
setting value
version R version 3.6.1 (2019-07-05)
os Ubuntu 18.04.2 LTS
system x86_64, linux-gnu
ui RStudio
language (EN)
collate en_US.UTF-8
ctype en_US.UTF-8
tz America/Indiana/Indianapolis
date 2019-07-17
─ Packages ───────────────────────────────────────────────────────────────────────────────────────
package * version date lib source
assertthat 0.2.1 2019-03-21 [1] CRAN (R 3.5.3)
backports 1.1.4 2019-04-10 [1] CRAN (R 3.6.0)
callr 3.3.0 2019-07-04 [1] CRAN (R 3.6.1)
cli 1.1.0 2019-03-19 [1] CRAN (R 3.5.3)
crayon 1.3.4 2017-09-16 [1] CRAN (R 3.5.1)
desc 1.2.0 2018-05-01 [1] CRAN (R 3.5.1)
devtools 2.1.0 2019-07-06 [1] CRAN (R 3.6.1)
digest 0.6.20 2019-07-04 [1] CRAN (R 3.6.1)
dplyr 0.8.3 2019-07-04 [1] CRAN (R 3.6.1)
fastmap 0.0.0.9001 2019-07-13 [1] Github (r-lib/fastmap@91321f1)
fs 1.3.1 2019-05-06 [1] CRAN (R 3.6.0)
g2r * 0.1.0 2019-07-18 [1] Github (JohnCoene/g2r@6d2b880)
glue 1.3.1 2019-03-12 [1] CRAN (R 3.6.0)
htmltools 0.3.6 2017-04-28 [1] CRAN (R 3.5.1)
htmlwidgets 1.3 2018-09-30 [1] CRAN (R 3.5.1)
httpuv 1.5.1 2019-04-05 [1] CRAN (R 3.5.3)
jsonlite 1.6 2018-12-07 [1] CRAN (R 3.5.1)
later 0.8.0 2019-02-11 [1] CRAN (R 3.5.2)
magrittr 1.5 2014-11-22 [1] CRAN (R 3.6.0)
memoise 1.1.0 2017-04-21 [1] CRAN (R 3.5.1)
mime 0.7 2019-06-11 [1] CRAN (R 3.6.0)
packrat 0.5.0 2018-11-14 [1] CRAN (R 3.5.1)
pillar 1.4.2 2019-06-29 [1] CRAN (R 3.6.1)
pkgbuild 1.0.3 2019-03-20 [1] CRAN (R 3.5.3)
pkgconfig 2.0.2 2018-08-16 [1] CRAN (R 3.5.1)
pkgload 1.0.2 2018-10-29 [1] CRAN (R 3.5.1)
prettyunits 1.0.2 2015-07-13 [1] CRAN (R 3.5.1)
processx 3.4.0 2019-07-03 [1] CRAN (R 3.6.1)
promises 1.0.1 2018-04-13 [1] CRAN (R 3.5.1)
ps 1.3.0 2018-12-21 [1] CRAN (R 3.5.2)
purrr 0.3.2 2019-03-15 [1] CRAN (R 3.5.3)
R6 2.4.0 2019-02-14 [1] CRAN (R 3.5.2)
Rcpp 1.0.1 2019-03-17 [1] CRAN (R 3.5.3)
remotes 2.1.0 2019-06-24 [1] CRAN (R 3.6.1)
rlang 0.4.0.9000 2019-07-13 [1] Github (r-lib/rlang@a3d7e47)
rprojroot 1.3-2 2018-01-03 [1] CRAN (R 3.5.1)
rsconnect 0.8.13 2019-01-10 [1] CRAN (R 3.5.2)
rstudioapi 0.10 2019-03-19 [1] CRAN (R 3.5.3)
sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 3.5.1)
shiny * 1.3.2.9001 2019-07-18 [1] Github (rstudio/shiny@1a8b36f)
testthat 2.1.1 2019-04-23 [1] CRAN (R 3.6.0)
tibble 2.1.3 2019-06-06 [1] CRAN (R 3.6.0)
tidyselect 0.2.5 2018-10-11 [1] CRAN (R 3.5.1)
usethis 1.5.1 2019-07-04 [1] CRAN (R 3.6.1)
withr 2.1.2 2018-03-15 [1] CRAN (R 3.5.1)
xtable 1.8-4 2019-04-21 [1] CRAN (R 3.6.0)
yaml 2.2.0 2018-07-25 [1] CRAN (R 3.6.0)
[1] /home/eric/R/x86_64-pc-linux-gnu-library/3.6
[2] /usr/local/lib/R/site-library
[3] /usr/lib/R/site-library
[4] /usr/lib/R/library
Hi Eric,
Sorry for the late response. The brush is indeed not working, I'll look into that!
Thanks for reporting it, and thanks for the Shiny series too :smiley: