Coder Social home page Coder Social logo

Plots in tabsets not rendered about shiny HOT 5 CLOSED

rstudio avatar rstudio commented on May 12, 2024 1
Plots in tabsets not rendered

from shiny.

Comments (5)

jcheng5 avatar jcheng5 commented on May 12, 2024

Hi Andrzej, I can't repro this behavior. Can you gist the entire modified ui.R file that demonstrates the problem? Or if you prefer, you can e-mail it to me at joe AT rstudio DOT org.

Thanks!

from shiny.

jcheng5 avatar jcheng5 commented on May 12, 2024

OK, I looked at the files you e-mailed me and the bug here is for plots that have "auto" width and/or height (the default) and are not visible at the time the page loads. If you switch to the Plots tab and resize the window you will see the plot snap into place. The problem here is the plot's size is 0x0 at the time the page loads, and we only update the plot size when the window size changes, not when switching tabs.

Good bug! We will fix this before release. In the meantime the only easy way I can think of to work around the bug is to set the width and height of the plot explicitly (i.e. pass width= and height= to reactivePlot).

from shiny.

jcheng5 avatar jcheng5 commented on May 12, 2024

Fixed in Shiny 0.1.3. Thanks!

from shiny.

agalecki avatar agalecki commented on May 12, 2024

Thank you Joe,

Two qs, if I may

  1. In 02_text example we choose one data set from a list (rock, pressure,
    cars).
    Then in the second step (I) would like to choose one variable from a
    list specific for selected data.
    In other words second choice/selection depends on the first. Is it
    possible (without html file)?
  2. In 06_tabsets example I tried to replace radioButtons() with a set of
    tabPanels() and maintain similar functionality. "dist" value is being
    updated as needed, but plot in the main panel is not (always normal). ui.R
    is included below.

Thank you in advance

A.

library(shiny)

Define UI for random distribution application

shinyUI(pageWithSidebar(

Application title

headerPanel("Tabsets"),

Sidebar with controls to select the random distribution type

and number of observations to generate. Note the use of the br()

element to introduce extra vertical spacing

sidebarPanel(
tabsetPanel(
tabPanel("Normal", textInput("dist","Xdist1", c("norm"))),
tabPanel("Uniform", textInput("dist","Xdist2", c("unif"))),
tabPanel("Log-normal", textInput("dist","Xdist3", c("lnorm"))),
tabPanel("Exponential", textInput("dist","Xdist4", c("exp")))
),
br(),
sliderInput("n",
"Number of observations:",
value = 500,
min = 1,
max = 1000)
),

Show a tabset that includes a plot, summary, and table view

of the generated distribution

mainPanel(
tabsetPanel(
tabPanel("Summary", verbatimTextOutput("summary")),
tabPanel("Plot", plotOutput("plot")),
tabPanel("Table", tableOutput("table"))
)
)
))

On Mon, Aug 20, 2012 at 6:02 PM, Joe Cheng [email protected] wrote:

Fixed in Shiny 0.1.3. Thanks!


Reply to this email directly or view it on GitHubhttps://github.com//issues/10#issuecomment-7885127.

from shiny.

jcheng5 avatar jcheng5 commented on May 12, 2024

I made a couple of tweaks to your code that should give you what you want.

library(shiny) 

# Define UI for random distribution application 
shinyUI(pageWithSidebar( 

  # Application title 
  headerPanel("Tabsets"), 

  # Sidebar with controls to select the random distribution type 
  # and number of observations to generate. Note the use of the br() 
  # element to introduce extra vertical spacing 
  sidebarPanel( 
    tabsetPanel(id='dist',
      tabPanel("Normal", value='norm', textInput("dist1","Xdist1", c("norm"))), 
      tabPanel("Uniform", value='unif', textInput("dist2","Xdist2", c("unif"))), 
      tabPanel("Log-normal", value='lnorm', textInput("dist3","Xdist3", c("lnorm"))), 
      tabPanel("Exponential", value='exp', textInput("dist4","Xdist4", c("exp"))) 
    ), 
    br(), 
    sliderInput("n", 
                "Number of observations:", 
                value = 500, 
                min = 1, 
                max = 1000) 
  ), 

  # Show a tabset that includes a plot, summary, and table view 
  # of the generated distribution 
  mainPanel( 
    tabsetPanel( 
      tabPanel("Summary", verbatimTextOutput("summary")), 
      tabPanel("Plot", plotOutput("plot")), 
      tabPanel("Table", tableOutput("table")) 
    ) 
  ) 
)) 

First, notice that tabsetPanel now has an id, and the tabPanel calls under it now have values. If you want the currently selected tab to take the place of the radio buttons in the original example, this is how you do it. Then inside the tab, you can put whatever you want (I'm guessing not the textboxes you had in your example).

One other thing to note about your code was that you had four textInputs with the same value for id. Even if they are on different tabs, all IDs in a page must be unique or else the results will be undefined--i.e. even if they work as you want them to in Shiny 0.1.3, they could break at any time. Hopefully though, this limitation should be easy to work around--if not, please let me know.

Thanks!

from shiny.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.