【问题标题】:Centering graph in Shiny tabBoxShiny tabBox中的居中图
【发布时间】:2019-01-22 18:21:28
【问题描述】:

我似乎无法将饼图置于 tabBox 中间。这是一些假数据:

Source = c("LinkedIn", "Google", "Indeed", "Friend", "Past Presentation")
Number = c(35,22,29,12,19)

Source = data.frame(Source, Number)

以及情节的代码:

barSource = plot_ly(Source, labels = ~Source, values = ~Number, type = 'pie', 
                    textposition = 'inside',
                    textinfo = 'label+percent',
                    insidetextfont = list(color = "#FFFFFF"),
                    hoverinfo = 'none', 
                    marker = list(colors = c(orange, light_blue, dark_blue,grey, 'rgba(238,118,0,.7)', 'rgba(114,147,203, 0.7)'),
                                line = list(color = '#FFFFFF', width = 1))) %>% 
                    layout(
                      title = "",
                      width = 650, 
                      height = 650,
                      xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
                      yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE)) %>% 
                    config(displayModeBar = F)

这是 UI 中标签框的代码

shinyUI(bootstrapPage(
  tags$head(tags$style(
    type="text/css",
    "#Education img, #Gender img, #Country img, #Source img {
        width: 60%;
        display: block;
        margin-left: auto;
        margin-right: auto;
    }"
  )),
  tabsetPanel(
    id = "demog", height = "800px", width = "800px",
              tabPanel("Source", barSource)
  )
))

目前,它是这样的:

感谢您的帮助。

【问题讨论】:

    标签: shiny plotly shiny-server shinydashboard r-plotly


    【解决方案1】:

    可能有一个“更清洁”的解决方案,但您可以使用 fluidRows 解决问题:

    tabsetPanel(
        id = "demog", 
        height = "800px", 
        width = "800px",
        tabPanel("Source", 
                 fluidRow(column(4),
                          column(4,barSource),
                          column(4)
                         ) # end of fluidRow
                 ) # end of tabPanel
    ) # end of tabsetPanel
    

    【讨论】:

      猜你喜欢
      • 2018-04-12
      • 2019-05-04
      • 2021-11-19
      • 2016-09-24
      • 2014-09-28
      • 2017-01-30
      • 1970-01-01
      • 2022-06-10
      • 2019-01-28
      相关资源
      最近更新 更多