dq_gallery: Creates a content gallery element

Description Usage Arguments Value Author(s) Examples

View source: R/dq_gallery.R

Description

Creates a gallery element with buttons to switch between several content elements.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
dq_gallery(
  id = NULL,
  ...,
  style = NULL,
  content_style = NULL,
  arrows = NULL,
  scrollable = FALSE
)

update_dq_gallery(id, set = NULL, add = NULL)

Arguments

id

optional element id, useful if current state is needed

...

content elements to show, names can be used to show titles

style, content_style

optional character specifying additional styles

arrows

optional list of arrows to use, by default defined as list( dq_icon("chevron-left"), dq_icon("chevron-right")), can be a list of other icons or freely designed html elements

scrollable

optional logical to specify if the gallery can be moved with a scrollbar (this option will hide arrows)

set

index of the content element to show

add

numeric amount of indexes to move (can also be negative)

Value

gallery element tag

Author(s)

richard.kunze

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
## Only run examples in interactive R sessions
if (interactive()) {

library(shiny)
shinyApp(
  ui = fluidPage(
    fluidRow(
      column(6, dq_gallery(id = "myGallery",
        Plot1 = plotOutput("plot1"), Plot2 = plotOutput("plot2"),
        plotOutput("plot3"), plotOutput("plot4"),
        content_style = "padding: 10px 30px;", arrows = list(
          dq_icon("chevron-circle-left"), dq_icon("chevron-circle-right")
        )
      )),
      column(6,
        actionButton("show3", "Show plot 3"),
        actionButton("anim", "Animate Plots")
      )
    )
  ),
  server = function(input, output) {
    output$plot1 <- renderPlot(plot(mtcars$mpg, mtcars$cyl))
    output$plot2 <- renderPlot(plot(mtcars$disp, mtcars$hp))
    output$plot3 <- renderPlot(plot(mtcars$drat, mtcars$wt))
    output$plot4 <- renderPlot(plot(mtcars$qsec, mtcars$vs))

    observeEvent(input$show3, update_dq_gallery("myGallery", set = 3))
    observeEvent(input$anim, {
      for(i in 1:30) {update_dq_gallery("myGallery", add = .1);Sys.sleep(.2)}
    })
  }
)

}

daqana/dqshiny documentation built on Sept. 1, 2020, 4:31 p.m.