r - Change size of image with a slider in Shiny -
goal: make image change size in response moving slider in shiny (rstudio). think zoom-in-zoom-out effect.
problem: there's error saying "error in basename(imageinfo$src) : character vector argument expected". can't find directly answers question , i'm not sure else try. problem how sliderinput used input$slider in server.r?
my current progress: rational set slider in ui.r file , have width of image input in server.r file.
the ui.r part:
shinyui(fluidpage( titlepanel("nancy's brainstorming"), sidebarlayout( sidebarpanel( h3( strong("what this?", style = "font-si24pt")), p("this pilot project."), sliderinput("slider", label = "", min = 100, max = 300, value = 200), imageoutput("logo", width = 200) ) ) ))
the server.r part:
shinyserver(function(input, output) { output$logo = renderimage({ img(src = "mylogo.png", width = input$slider) }) })
additional information: image shows fine when use img(src = "mylogo.png", width = 200). also, i'm doing better feel building shiny apps.
img(src = "mylogo.png", width = input$slider)
returning html. can use renderui
instead of renderimage
.
library(shiny) runapp( list(ui = fluidpage( titlepanel("nancy's brainstorming"), sidebarlayout( sidebarpanel( h3( strong("what this?", style = "font-si24pt")), p("this pilot project."), sliderinput("slider", label = "", min = 100, max = 300, value = 200), uioutput('logo') ), mainpanel( plotoutput("distplot") ) ) ), server = function(input, output, session) { output$logo <- renderui({ img(src = "http://i.stack.imgur.com/mtqxa.png", width = as.integer(input$slider)) }) } ) )
Comments
Post a Comment