我似乎无法将饼图居中于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)
这是用户界面中选项卡的代码
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)
)
))
感谢您的帮助。
答案 0 :(得分:0)
可能有一个“更清洁”的解决方案,但是您可以使用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