Search code examples
rshinydashboardr-highcharter

Highcharter treemap not rendering in shinydashboard


The treemap was working fine in shiny but when I converted to shinydashboard the treemap stopped working. It just show a blank block now. Any ideas how to fix this?

This is in my server.R

  output$TreeMap<-renderHighchart2({TM1<-hctreemap2(data = M,
                                                    group_vars = c("Status","Class","Order", "Family","Species"),
                                                    size_var = "n",
                                                    color_var = "n",
                                                    layoutAlgorithm = "squarified",
                                                    levelIsConstant = T,
                                                    levels = list(
                                                      list(level = 1, dataLabels = list(enabled = T)),
                                                      list(level = 2, dataLabels = list(enabled = F)),
                                                      list(level = 3, dataLabels = list(enabled = F)),
                                                      list(level = 4, dataLabels = list(enabled = F)),
                                                      list(level = 5, dataLabels = list(enabled = F))
                                                    )) %>% 
    hc_colorAxis(minColor = brewer.pal(9, "GnBu")[6],
                 maxColor = brewer.pal(9, "YlOrRd")[8]) %>% 
    hc_tooltip(pointFormat = "<b>{point.name}</b>:<br>
               Number Measured: {point.value:,.0f}")
  })

This is in my ui.R

tabItem(tabName = "About",
            tabsetPanel(
              tabPanel("TreeMap",box(width = 12,highchartOutput2("TreeMap",height = "750px"))))

Solution

  • The problem was that I had renderHighchart2 and highchartOutput2 also in the script.I changed them all to renderHighchart and highchartOutput now everything works again. So, for some reason you can't have both in your script, possibly, I don't know.