r闪亮错误:html工具中的错误:: vartatecssunit(height);CSS单元必须是单元素数字或字符向量



am学习使用r Shiny,我正在尝试创建一个热图,该热图允许用户指定plotlyOutput中的高度,以防止标签被团结在一起。我的最小工作代码:

library(shiny)
library(plotly)
ui <- fluidPage(
titlePanel("Heatmap"),
sidebarLayout(
sidebarPanel(
  sliderInput("mapHeight", 
              "Heatmap Height", 
               min = 500, 
               max = 1000,
               value =500),
  sliderInput("L", "left adjust", min = 0, max =900, value = 80)
  ),
  mainPanel(plotlyOutput("heatmap"))
  )
  )
server <- function(input, output) {
 output$heatmap <- renderPlotly({ 
 p<- heatmaply(mtcars, plot_method = "plotly")%>% 
  layout(margin = list(l = input$L, r =50 , t=0, b=90))
 #not sure why this is being ignored
 ggplotly(p, height = input$mapHeight)
 })
 }
shinyApp(ui = ui, server = server)

约束与heatmaply软件包有关,下面的解决方案是暂时的,而plotly继续接受height中的CC_3参数。

警告:现在不弃用布局((中指定宽度/高度。 请在ggplotly((或plot_ly((

中指定

您可以在其GitHub上与开发人员联系,并提出和发行更好,或者通过您提出的更改提出拉动请求。目前,下面的解决方案可与Plotly 4.7.1。

一起使用

app.r

library(shiny)
library(heatmaply)
ui <- fluidPage(
  titlePanel("Heatmap"),
  sidebarLayout(
    sidebarPanel(
      sliderInput("mapHeight", "Heatmap Height",
                  min = 500, max = 1000, value = 500),
      sliderInput("L", "left adjust", min = 0, max = 900, value = 80)
    ),
    mainPanel(plotlyOutput("heatmap"))
  )
)
server <- function(input, output) {
  output$heatmap <- renderPlotly({
    heatmaply(mtcars) %>%
      layout(margin = list(l = input$L, r = 50, t = 0, b = 90),
             height = input$mapHeight)
  })
}
shinyApp(ui = ui, server = server)

最新更新