Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RShiny dynamic Popup (can move)

I work on a dashboard and I would like to create a dynamic popup , ie we can move. I can create a pop-up but this one is static, I like that one can take it and move it to the right, left ...

A example of my pop up :

library(shiny)
library(shinyBS)

shinyApp(

  ui =
    fluidPage(
      sidebarLayout(
        box(actionButton("tabBut", "View Table")),
        mainPanel(
          bsModal("modalExample", "Data Table", "tabBut", size = "large",
                  dataTableOutput("distTable"))))),

  server =
    function(input, output, session) {
      output$distTable <- renderDataTable({
        x    <- faithful[, 2]
        bins <- seq(min(x), max(x), length.out = 30 + 1)
        tab <- hist(x, breaks = bins, plot = FALSE)
        tab$breaks <- sapply(seq(length(tab$breaks) - 1), function(i) {
          paste0(signif(tab$breaks[i], 3), "-", signif(tab$breaks[i+1],    3))})
        tab <- as.data.frame(do.call(cbind, tab))
        colnames(tab) <- c("Bins", "Counts", "Density")
        return(tab[, 1:3])}, 
        options = list(pageLength=10))}
)

result

And I want that the user can move this window. If you have ideas of option to change, or so if you know any means other than BS Shiny on to create new window...

Thank you in advance and sorry for my English !

like image 356
CClaire Avatar asked Dec 19 '25 12:12

CClaire


1 Answers

You can try to do it manyally :

1) Add script

2) add draggable

3) edit css

like:

 ui =
    fluidPage(
      tags$head(HTML('<script src="//code.jquery.com/jquery-1.10.2.js"></script>
                    <script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>')),
        tags$script(HTML('  $(window).load(function(){
                        $("#modalExample").draggable({
                        handle: ".modal-header"
                                   });
                                   });')),
            tags$style(HTML("
            .modal-backdrop.in {
                opacity: 0;
            }    
                ")),
      sidebarLayout(
        box(actionButton("tabBut", "View Table")),
        mainPanel(

          bsModal("modalExample", "Data Table", "tabBut", size = "large",
                  dataTableOutput("distTable")))))
like image 65
Batanichek Avatar answered Dec 21 '25 02:12

Batanichek



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!