当试图在Shiny中制作高图树图时,我遇到了这个奇怪的事情。如果不满足验证高图的条件,我会使用我的验证消息(而不仅仅是文本)获取此交互式文本树图。
我做错了什么或者这只是Highchart中的一个错误?
## app.R ##
require(shiny)
require(treemap)
require(highcharter)
ui <- fluidPage(numericInput(inputId = "n",
"Input number", value = 1),
highchartOutput("tree"))
server <- function(input, output, session) {
data(GNI2014)
tm <- treemap(
GNI2014,
index = c("continent", "iso3"),
vSize = "population",
vColor = "GNI",
type = "value"
)
output$tree <- renderHighchart({
validate(need(input$n == 1, "Please input number 1"))
hctreemap(tm = tm)
})
}
shinyApp(ui, server)
答案 0 :(得分:1)
以下是使用renderUI
## app.R ##
require(shiny)
require(treemap)
require(highcharter)
ui <- fluidPage(numericInput(inputId = "n","Input number", value = 1),
htmlOutput("tree"))
server <- function(input, output, session) {
data(GNI2014)
tm <- treemap(
GNI2014,
index = c("continent", "iso3"),
vSize = "population",
vColor = "GNI",
type = "value"
)
output$tree <- renderUI({
validate(need(input$n == 1, "Please input number 1"))
if(input$n != 1){
h1 <- highchart()
}
else{
h1 <- hctreemap(tm = tm)
}
hw_grid(h1,rowheight = 390)
})
}
shinyApp(ui, server)