简体   繁体   English

如何在R Shiny中调整sidebarPanel的宽度而不影响后续的sidebarPanel宽度

[英]How to adjust the width of sidebarPanel without affect subsequent sidebarPanel widths in R Shiny

I am trying to change the width of the sidebarPanel in R Shiny so that my mainPanel has more 'room' to display two graphs side-by-side. 我试图在R Shiny中更改sidebarPanel的宽度,以便我的mainPanel具有更多的“房间”来并排显示两个图形。 The graphs are displayed in their respective sidebarPanels in the mainPanel. 图形显示在mainPanel中它们各自的侧边栏中。 Hence there are three sidebarPanels: the first used for data selection/choice for display in the remaining two sidebarPanels. 因此,共有三个sidebarPanels:第一个用于数据选择/选择,以显示在其余两个sidebarPanels中。

However, when I change the width of this first sidebarPanel, all the sidebarPanels take on this width. 但是,当我更改第一个sidebarPanel的宽度时,所有sidebarPanels都采用此宽度。 How do I prevent this from happening ? 如何防止这种情况发生?

The ui.r code I am using as an example is found at: https://github.com/EconometricsBySimulation/2013-06-11-Shiny-Exploration/blob/master/ui.R 我用作示例的ui.r代码位于: https : //github.com/EconometricsBySimulation/2013-06-11-Shiny-Exploration/blob/master/ui.R

And the server.r code example is found at: https://github.com/EconometricsBySimulation/2013-06-11-Shiny-Exploration/blob/master/server.R 并在以下位置找到server.r代码示例: https : //github.com/EconometricsBySimulation/2013-06-11-Shiny-Exploration/blob/master/server.R

I am using the following to adjust the width of the first sidebarPanel in the ui.r: 我正在使用以下内容来调整ui.r中第一个sidebarPanel的宽度:

left=sidebarPanel(
         tags$head(
           tags$style(type="text/css", "select { width: 100px; }"), # defines width of dropdown panel
           tags$style(type='text/css', ".span4 { max-width: 150px; }") # defines width of panel containing dropdown panel
           ),

But as noted this causes the subsequent panels to take on its width. 但是,如前所述,这将导致随后的面板采用其宽度。 Any ideas on how I can keep this or a narrower setting for the width of the first sidebarPanel, and have the widths of the second (middle) and third (right) sidebarPanels be each half the width of the remaining space ? 关于如何保持此宽度或将第一个sidebarPanel的宽度设置为更窄的宽度,并使第二个(中间)和第三个(右)sidebarPanels的宽度分别为剩余空间宽度的一半的任何想法?

Many thanks in advance! 提前谢谢了!

Using sidebarPanel looks a bit twisted to me, wellPanel might be a better choice. 使用sidebarPanel看起来有点扭曲, wellPanel可能是一个更好的选择。 Try the following: 请尝试以下操作:

 left=wellPanel(
   tags$style(type="text/css", '#leftPanel { width:200px; float:left;}'),
   id = "leftPanel",
   selectInput .... as before

This give the panel an id and assigns as style. 这将为面板提供一个ID并分配为样式。 Do something similar for the other panels. 对其他面板执行类似的操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM