When trying to make a highcharter treemap in Shiny I encountered this strange thing. When the condition for validate a highchart isn't met I get this interactive text treemap togehter with my validate message (instead of just the text).
Am I doing something wrong or is this just a bug within 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)
Here is a work around using the 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)