0

Friends, I would like to add a brief explanation about each filter used. Then, whenever you click on the filter name, a small window appears with a brief informative text about the meaning of that filter. I left an image attached to illustrate. So, for example, if I click on "Number of bins" the description of the meaning of this filter appears. Obviously, if you click outside that info window, the info text will exit.

How can I do this in shiny?

library(shiny)

ui <- fluidPage(


  titlePanel("Old Faithful Geyser Data"),

  sidebarLayout(
    sidebarPanel(
      sliderInput("bins",
                  "Number of bins:",
                  min = 1,
                  max = 50,
                  value = 30)
    ),

    sidebarLayout(
      sidebarPanel(
        sliderInput("bins",
                    "Number of bins:",
                    min = 1,
                    max = 20,
                    value = 30),
      ),
      mainPanel(
        plotOutput("distPlot")
      )
    )
  ))

server <- function(input, output) {

  output$distPlot <- renderPlot({
    # generate bins based on input$bins from ui.R
    x    <- faithful[, 2]
    bins <- seq(min(x), max(x), length.out = input$bins + 1)

    # draw the histogram with the specified number of bins
    hist(x, breaks = bins, col = 'darkgray', border = 'white')
  })
}

# Run the application 
shinyApp(ui = ui, server = server)


Thank you very much!

enter image description here

1 Answers1

0

You could use shinyBS for that - either bsTooltip, popify, or tipify. Example:

Edit: Switched to popify.



library(shinyBS)
library(shiny)

ui <- fluidPage(


    titlePanel("Old Faithful Geyser Data"),

    sidebarLayout(
        sidebarPanel(


            popify(
                sliderInput("bins",
                            "Number of bins:",
                            min = 1,
                            max = 20,
                            value = 30),
                title = "Number of bins",
                content = paste0("Number of bins refers to.....")
            )
            ),
            mainPanel(
                plotOutput("distPlot")
            )
        )
    )

server <- function(input, output) {

    output$distPlot <- renderPlot({
        # generate bins based on input$bins from ui.R
        x    <- faithful[, 2]
        bins <- seq(min(x), max(x), length.out = input$bins + 1)

        # draw the histogram with the specified number of bins
        hist(x, breaks = bins, col = 'darkgray', border = 'white')
    })
}

# Run the application 
shinyApp(ui = ui, server = server)

user12728748
  • 8,106
  • 2
  • 9
  • 14
  • Thanks for the reply friend. But the text box went black, could you leave it blank? –  May 07 '20 at 23:18
  • You could use popify, if you prefer that, or change the styling of bsTooltip. – user12728748 May 07 '20 at 23:34
  • Thanks friend for reply –  May 08 '20 at 01:59
  • user12728748, do you know to answer the following question: https://stackoverflow.com/questions/61721873/insert-popify-for-radiobuttons-options –  May 11 '20 at 14:57