admin管理员组文章数量:1399006
I would like to add a scrollbar to a barplot of plotly
. I tried using a div
with a style
to add a scrollbar. Unfortunately, this doesn't work. Here is a simple reproducible example:
library(plotly)
library(shiny)
ui <- page_fluid(
div(
style = "overflow-y: scroll; position: relative",
plotlyOutput(outputId = "plot")
)
)
server <- function(input, output, ...) {
output$plot <- renderPlotly({
df <- data.frame(
x = 1:26,
y = LETTERS
)
fig <- plot_ly(data = df, x = ~x, y = ~y, type = 'bar', orientation = 'h')
fig
})
}
shinyApp(ui, server)
Output:
As you can see in the output there is no scrollbar added. So I was wondering how we can add a scrollbar to a plotly graph to scroll through multiple bars so every labels will be visible?
I would like to add a scrollbar to a barplot of plotly
. I tried using a div
with a style
to add a scrollbar. Unfortunately, this doesn't work. Here is a simple reproducible example:
library(plotly)
library(shiny)
ui <- page_fluid(
div(
style = "overflow-y: scroll; position: relative",
plotlyOutput(outputId = "plot")
)
)
server <- function(input, output, ...) {
output$plot <- renderPlotly({
df <- data.frame(
x = 1:26,
y = LETTERS
)
fig <- plot_ly(data = df, x = ~x, y = ~y, type = 'bar', orientation = 'h')
fig
})
}
shinyApp(ui, server)
Output:
As you can see in the output there is no scrollbar added. So I was wondering how we can add a scrollbar to a plotly graph to scroll through multiple bars so every labels will be visible?
Share Improve this question asked Mar 25 at 13:18 QuintenQuinten 41.8k11 gold badges51 silver badges108 bronze badges Recognized by R Language Collective1 Answer
Reset to default 2You're almost there, but you need to specify some heights because otherwise the outer div will just expand to whatever height the plot is. e.g.:
div(
style = "overflow-y: scroll; position: relative; height: 400px",
plotlyOutput(outputId = "plot", height = "800px")
)
本文标签: shinyAdd vertical scrollbar to barplot plotly RStack Overflow
版权声明:本文标题:shiny - Add vertical scrollbar to barplot plotly R - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744193567a2594630.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论