0
votes

See code below. As it is works. If you un-comment the commented-out lines shiny drops the legend. It may well be a shiny bug. My app needs navbarPage. Anybody has any suggestion?? I use R version 3.1.1 & latest versions of packages (as of 6/10/2014)

library(WDI)
library(dplyr)
library(countrycode)
library(RColorBrewer)
library(plyr)
library(rMaps)
library(rCharts)
library(shiny)
#
runApp(list( ui =   
    # navbarPage("Maps", id = "maps",
    #           footer = "footer",
    tabPanel("Data Map", id="overview",h3("Data Maps!"), 
                showOutput("chart1", "datamaps")
                # )
), 
 server = function(input, output, session) {
output$chart1 <- renderChart2({
        df=WDI(country = "all", indicator = "SH.DYN.MORT",
               start = 2000, end = 2000, extra = FALSE, cache = NULL)
        data <- df %.% 
          na.omit() %.%

          mutate(iso3c=countrycode(iso2c, "iso2c", "iso3c")) %.% 
          group_by(iso3c) 

        i1 <- ichoropleth(SH.DYN.MORT~iso3c, data, map="world",labels=FALSE,pal="Reds")
        i1
    })
}))
1
@rmccloskey Re-edited code (eliminating the } that crept in!). Thanks for that. Added R version. - Enzo
I needed library(rMaps) as well. - Joe Cheng

1 Answers

0
votes

The bug appears to be in rCharts/rMaps, not in Shiny; both the map and its rCharts container are being set to 400 pixels high, but the legend is also included in the container. The legend is still there in all cases, but you have to scroll to see it when navbarPage is used. navbarPage seems to make the problem worse because it tells the tabPanel not to simply render content that's too large for it, but to do scrolling instead.

You can confirm that this is a problem even without navbarPage by simply adding the string "hello" as another argument to tabPanel, right after the showOutput() call; you'll see that "hello" is rendered between the map and the legend, when it should appear below the legend.