rstudio / crosstalk

Inter-htmlwidget communication for R (with and without Shiny)
http://rstudio.github.io/crosstalk
Other
287 stars 52 forks source link

problem selecting barplot elements #46

Open yonicd opened 6 years ago

yonicd commented 6 years ago

how can i select barplots with crosstalk?

library(crosstalk)
library(plotly)
shared_data <- SharedData$new(data.frame(x=1:10,y=rnorm(10),z=sample(1:4,10,replace = TRUE)),key = ~x)

p1 <- plot_ly(shared_data,x=~x,y=~y,text=~z,type='bar')%>%highlight(on = 'plotly_click',color='red')
p2 <- plot_ly(shared_data,x=~x,y=~abs(y),text=~z,type='bar')%>%highlight('plotly_click',color='red')
p3 <- plot_ly(shared_data,x=~x,y=~y,text=~z,type='scatter',mode='markers')%>%highlight('plotly_selected',color='red')

bscols(subplot(p1_ly, subplot(p2_ly,p3_ly,nrows=1),nrows=2))
Session info ---------------------------------------------------------------------------------------------
 setting  value                       
 version  R version 3.3.3 (2017-03-06)
 system   x86_64, darwin13.4.0        
 ui       RStudio (1.1.383)           
 language (EN)                        
 collate  en_US.UTF-8                 
 tz       America/New_York            
 date     2018-02-05                  

Packages -------------------------------------------------------------------------------------------------
 package      * version    date       source                            
 assertthat     0.2.0      2017-04-11 CRAN (R 3.3.2)                    
 base         * 3.3.3      2017-03-07 local                             
 bindr          0.1        2016-11-13 CRAN (R 3.3.2)                    
 bindrcpp       0.2        2017-06-17 CRAN (R 3.3.2)                    
 colorspace     1.3-2      2016-12-14 CRAN (R 3.3.2)                    
 crosstalk    * 1.0.1      2018-02-05 Github (rstudio/crosstalk@0a3b8f4)
 curl           3.1        2017-12-12 CRAN (R 3.3.2)                    
 data.table     1.10.4-3   2017-10-27 CRAN (R 3.3.2)                    
 datasets     * 3.3.3      2017-03-07 local                             
 devtools       1.13.4     2017-11-09 CRAN (R 3.3.2)                    
 digest         0.6.13     2017-12-14 CRAN (R 3.3.2)                    
 dplyr          0.7.4      2017-09-28 CRAN (R 3.3.2)                    
 ggplot2      * 2.2.1.9000 2018-02-04 Github (hadley/ggplot2@a2dc248)   
 glue           1.2.0      2017-10-29 CRAN (R 3.3.2)                    
 graphics     * 3.3.3      2017-03-07 local                             
 grDevices    * 3.3.3      2017-03-07 local                             
 grid           3.3.3      2017-03-07 local                             
 gtable         0.2.0      2016-02-26 CRAN (R 3.3.0)                    
 htmltools      0.3.6      2017-04-28 CRAN (R 3.3.2)                    
 htmlwidgets    0.9        2017-07-10 CRAN (R 3.3.2)                    
 httpuv         1.3.5      2017-07-04 CRAN (R 3.3.2)                    
 httr           1.3.1      2017-08-20 CRAN (R 3.3.2)                    
 jsonlite       1.5        2017-06-01 CRAN (R 3.3.2)                    
 lazyeval       0.2.1      2017-10-29 CRAN (R 3.3.2)                    
 magrittr       1.5        2014-11-22 CRAN (R 3.3.0)                    
 memoise        1.1.0      2017-04-21 CRAN (R 3.3.2)                    
 methods      * 3.3.3      2017-03-07 local                             
 mime           0.5        2016-07-07 CRAN (R 3.3.0)                    
 munsell        0.4.3      2016-02-13 CRAN (R 3.3.0)                    
 pkgconfig      2.0.1      2017-03-21 CRAN (R 3.3.2)                    
 plotly       * 4.7.1      2017-07-29 CRAN (R 3.3.2)                    
 plyr           1.8.4      2016-06-08 CRAN (R 3.3.0)                    
 purrr          0.2.4      2017-10-18 CRAN (R 3.3.2)                    
 R6             2.2.2      2017-06-17 CRAN (R 3.3.2)                    
 RColorBrewer   1.1-2      2014-12-07 CRAN (R 3.3.0)                    
 Rcpp           0.12.14    2017-11-23 CRAN (R 3.3.2)                    
 remotes        1.1.1      2017-12-20 CRAN (R 3.3.2)                    
 rgeolocate     1.0.1      2017-08-02 CRAN (R 3.3.2)                    
 rlang          0.1.6.9003 2018-02-04 Github (tidyverse/rlang@c6747f9)  
 scales         0.5.0.9000 2017-11-16 Github (hadley/scales@d767915)    
 shiny          1.0.5      2017-08-23 CRAN (R 3.3.2)                    
 stats        * 3.3.3      2017-03-07 local                             
 tibble         1.3.4      2017-08-22 CRAN (R 3.3.2)                    
 tidyr          0.7.2      2017-10-16 CRAN (R 3.3.2)                    
 tools          3.3.3      2017-03-07 local                             
 utils        * 3.3.3      2017-03-07 local                             
 viridisLite    0.2.0      2017-03-24 CRAN (R 3.3.2)                    
 withr          2.1.1.9000 2018-02-04 Github (jimhester/withr@df18523)  
 xtable         1.8-2      2016-02-05 CRAN (R 3.3.0)                    
 yaml           2.1.16     2017-12-12 CRAN (R 3.3.2)
cpsievert commented 6 years ago

See here https://community.rstudio.com/t/crosstalk-with-barplots/4900

cpsievert commented 6 years ago

@jcheng5 feel free to close this issue

yonicd commented 6 years ago

doing what you suggested made my rstudio session freeze with spinning colour wheel

(one time occurrence , can't recreate it now)