nvd3.js - Chart not rendering with Shiny R and NVD3 -


i have been attempting create shiny timeseries plot using nvd3 library. relatively new r, shiny , nvd3. problem when run shinyapp, no chart renders on browser. using chromes developer tools, can see div mychart created , populated data, not understanding why cannot see chart itself.

would appreciate , on matter... code so:

#ui.r require(rcharts)  shinyui(pagewithsidebar(   headerpanel("population trend age group:"),    sidebarpanel(     selectinput(inputid = "agegrp",                 label = "choose agegroup",                 choices = c("0-4",                             "5-9",                             "10-14",                             "15-19",                             "20-24",                             "25-29",                             "30-34",                             "35-39",                             "40-44",                             "45-49",                             "50-54",                             "55-59",                             "60-64",                             "65-69",                             "70-74",                             "75-79",                             "80-84",                             "85+"                 ),                 selected = "0-4")   ),   mainpanel(     showoutput("mychart", "nvd3")   ) )) 

server.r:

#server.r require(rcharts)  data <- read.csv("https://raw.githubusercontent.com/kilimba/data/master/data2.csv") agegroup_mapping <- read.csv("https://raw.githubusercontent.com/kilimba/data/master/agegroup.csv") data <- merge(data,agegroup_mapping,by.x="agegrp",by.y="agegroup")   shinyserver(function(input, output) {    output$mychart <- renderchart({      selection <- subset(data,mapping == input$agegrp)      plot <- nplot(n ~ year,                   data = selection,                   type = "linechart",                   group = "sex")     # add axis labels , format tooltip     plot$yaxis(axislabel = "population", width = 62)      plot$xaxis(axislabel = "year")      plot$save("ac.html")     return(plot)        }) }) 

thanks, tumaini

use renderchart2 instead of renderchart.

rm(list = ls()) library(shiny) library(rcharts)  data <- read.csv("https://raw.githubusercontent.com/kilimba/data/master/data2.csv") agegroup_mapping <- read.csv("https://raw.githubusercontent.com/kilimba/data/master/agegroup.csv") data <- merge(data,agegroup_mapping,by.x="agegrp",by.y="agegroup")  ui =pagewithsidebar(   headerpanel("population trend age group:"),    sidebarpanel(     selectinput(inputid = "agegrp",                 label = "choose agegroup",                 choices = c("0-4","5-9","10-14","15-19","20-24","25-29","30-34","35-39",                             "40-44","45-49","50-54","55-59","60-64","65-69","70-74","75-79","80-84","85+"),selected = "0-4"),width=2),   mainpanel(     showoutput("mychart", "nvd3")   ) )  server = function(input, output) {    output$mychart <- renderchart2({     #selection <-  data[data$mapping == "0-4",]     selection <- data[data$mapping == input$agegrp,]      selection <- subset(data,mapping == input$agegrp)      plot <- nplot(n ~ year,                   data = selection,                   type = "linechart",                   group = "sex")     # add axis labels , format tooltip     plot$yaxis(axislabel = "population", width = 62)     plot$xaxis(axislabel = "year")     plot$set(width=1600, height=800)      plot$save("ac.html")     plot   }) }   runapp(list(ui = ui, server = server)) 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -