r - Formatting/aligning rCharts (nvd3) in shiny app -


i developing shiny app hope picture below: enter image description here

however, try achieve this, able following form:

enter image description here enter image description here

i looking how make output neatly collected, , appreciate help. have looked @ couple of other similar questions here, viz. this , this, don't think answer question (the first talks adding mainpanel, using fludipage , fluidrows. had thought columns , rows automatically adjust screen size, , 12 columns designed fit screen size, apparently wrong?

many help.

the server.r file copying/pasting. apologies, bit long:

# # # load libraries, scripts, data  library(shiny) library(shinyapps) library(shinydashboard) library(dplyr) library(tidyr) library(lubridate) library(htmlwidgets)  options(shiny.trace = true,       shiny.maxrequestsize=300*1024^2)    ## body of shiny server side program  shinyserver(function(input, output, session) {   datalist <- reactive({         if(is.null(input$uploadfile)){              return(null)         }         uploadfileinfo <- input$uploadfile         uploaddata <- read.csv(uploadfileinfo$datapath, header = true, stringsasfactors = false)          uploadeddata <- tbl_df(uploaddata) %>%                  mutate(yearvalue = year(datevalues), monthvalue = month(datevalues))          sumdata1 <- uploadeddata %>%              select(yearvalue, earnpts, earncount, redempts, redemcount, churncount, acquiscount) %>%              gather(metrics, totals, -yearvalue) %>%             group_by(yearvalue, metrics) %>%             summarise(yearlytotals = sum(totals)) %>%             arrange(yearlytotals)          sumdata2 <- uploadeddata %>%               select(yearvalue, monthvalue, earnpts, earncount, redempts, redemcount, churncount, acquiscount) %>%             gather(metrics, totals, -c(yearvalue, monthvalue)) %>%             group_by(yearvalue, monthvalue, metrics) %>%             summarise(yearmonthtotals = sum(totals)) %>%             arrange(yearvalue, monthvalue) %>%             group_by(yearvalue, metrics) %>%             mutate(cumulatives = cumsum(yearmonthtotals))          sumdata3 <- uploadeddata %>%              select(yearvalue, monthvalue, earnpts, earncount, redempts, redemcount, churncount, acquiscount) %>%             group_by(yearvalue, monthvalue) %>%             summarise_each(funs(mean)) %>%              round()          sumdata4 <- uploadeddata %>%              group_by(datevalues) %>%             summarise_each(funs(sum))          earndata <- sumdata4 %>%             select(earnpts, earncount)         row.names(earndata) <- sumdata4$datevalues          redempdata <- sumdata4 %>%             select(redempts, redemcount)         row.names(earndata) <- sumdata4$datevalues          custdata <- sumdata4 %>%             select(churncount, acquiscount)         row.names(earndata) <- sumdata4$datevalues          sumdata5 <- uploadeddata %>%              group_by(datevalues) %>%             summarise_each(funs(sum))          earntsdata <- sumdata5 %>%             select(earnpts, earncount)         row.names(earntsdata) <- sumdata5$datevalues          redemtsdata <- sumdata5 %>%             select(redempts, redemcount)         row.names(redemtsdata) <- sumdata5$datevalues          custtsdata <- sumdata5 %>%             select(acquiscount, churncount)         row.names(custtsdata) <- sumdata5$datevalues           dflist <- list(sumdata1 = sumdata1, sumdata2 = sumdata2, sumdata3 = sumdata3,                    sumdata4 = sumdata4, earndata = earndata, redempdata = redempdata,                    custdata = custdata, sumdata5 = sumdata5, earntsdata = earntsdata,                    redemtsdata = redemtsdata, custtsdata = custtsdata)          return(dflist) })   ### main chart  output$outlineschart <- renderchart2({     mydata <- datalist()$sumdata1     mainplot <- nplot(yearlytotals ~ metrics,                group = 'yearvalue', data = mydata, type = 'multibarchart')     mainplot$chart(margin=list(left=100))      rm(mydata)     return(mainplot) })   ### information boxes  output$infobox1 <- renderinfobox({     infobox(       "progress", 10*2, icon = icon("line-chart"),       color = "blue"     ) })  output$infobox2 <- renderinfobox({     infobox(       "progress", 10*2, icon = icon("line-chart"),       color = "blue"     ) })  output$infobox3 <- renderinfobox({     infobox(       "progress", 10*2, icon = icon("line-chart"),       color = "blue"     ) })  output$infobox4 <- renderinfobox({     infobox(       "progress", 10*2, icon = icon("line-chart"),       color = "blue"     ) })  output$infobox5 <- renderinfobox({     infobox(       "progress", 10*2, icon = icon("smile-o"),       color = "blue"     ) })  output$infobox6 <- renderinfobox({     infobox(       "progress", 10*2, icon = icon("frown-o"),       color = "purple", fill = true     ) })    ### cumulative chart points earned  output$cearnptschart <- renderchart2({     mydata <- datalist()$sumdata2     interimdata <- mydata %>% filter( metrics == 'earnpts')     myplot <- nplot(cumulatives ~ monthvalue, group = 'yearvalue',              data = interimdata, type = 'linechart')     rm(mydata)     rm(interimdata)     return(myplot) })   ### cumulative chart count of earn transactions  output$cearncountchart <- renderchart2({     mydata <- datalist()$sumdata2     interimdata <- mydata %>% filter( metrics == 'earncount')     myplot <- nplot(cumulatives ~ monthvalue, group = 'yearvalue',              data = interimdata, type = 'linechart')     rm(mydata)     rm(interimdata)     return(myplot) })   ### cumulative chart points redeemed  output$credemptschart <- renderchart2({     mydata <- datalist()$sumdata2     interimdata <- mydata %>% filter( metrics == 'redempts')     myplot <- nplot(cumulatives ~ monthvalue, group = 'yearvalue',              data = interimdata, type = 'linechart')     rm(mydata)     rm(interimdata)     return(myplot) })   ### cumulative chart count of redemption transactions  output$credemcountchart <- renderchart2({     mydata <- datalist()$sumdata2     interimdata <- mydata %>% filter( metrics == 'redemcount')     myplot <- nplot(cumulatives ~ monthvalue, group = 'yearvalue',              data = interimdata, type = 'linechart')     rm(mydata)     rm(interimdata)     return(myplot) })   ### cumulative chart customer acquisition  output$cacquischart <- renderchart2({     mydata <- datalist()$sumdata2     interimdata <- mydata %>% filter( metrics == 'acquiscount')     myplot <- nplot(cumulatives ~ monthvalue, group = 'yearvalue',              data = interimdata, type = 'linechart')     rm(mydata)     rm(interimdata)     return(myplot) })   ### cumulative chart customer acquisition  output$cchurnchart <- renderchart2({     mydata <- datalist()$sumdata2     interimdata <- mydata %>% filter( metrics == 'churncount')     myplot <- nplot(cumulatives ~ monthvalue, group = 'yearvalue',              data = interimdata, type = 'linechart')     rm(mydata)     rm(interimdata)     return(myplot) })   }) 

the ui.r file:

### load libraries  library(shiny) library(shinythemes)   ### body shiny ui   shinyui(navbarpage("my sample dashboard", theme = shinytheme('readable'), inverse = true,         tabpanel("overview section",             fluidrow(                 column(6,                      ##current app supports csv, since proof of concept...                     fileinput(inputid = 'uploadfile', label = 'please upload file')                     )                   ),             fluidrow(                 column(3,                      h4('main chart goes here'),                      showoutput('outlineschart', 'nvd3')                     ),                 column(3, offset = 5,                      h5('info boxes go here'),                      infoboxoutput('infobox1'),                      infoboxoutput('infobox2'),                      infoboxoutput('infobox3'),                      infoboxoutput('infobox4'),                      infoboxoutput('infobox5'),                      infoboxoutput('infobox6')                     )                    ),             hr(),             fluidrow(                 column(2,                       h5('earned points chart goes here'),                     showoutput('cearnptschart', 'nvd3')                     ),                 column(2, offset = 4,                     h5('earn count chart goes here'),                     showoutput('cearncountchart', 'nvd3')                     )                    ),             fluidrow(                 column(2,                       h5('redeemed points chart goes here'),                      showoutput('credemptschart', 'nvd3')                     ),                 column(2, offset = 4,                     h5('redemption count chart goes here'),                      showoutput('credemcountchart', 'nvd3')                     )                    ),             fluidrow(                 column(2,                       h5('customer acquisition chart goes here'),                      showoutput('cacquischart', 'nvd3')                     ),                 column(2, offset = 4,                     h5('customer churn chart goes here'),                      showoutput('cchurnchart', 'nvd3')                     )                    )               ),         tabpanel("details section"),         tabpanel("experiments section")) ) 

edit:

following code generate csv file fed app.

earnptsrange <- 12000:18000 earncountrange <- 1000:10000 redemptsrange <- 10000:20000 redemcountrange <- 10000:20000 churnrange <- 1000:10000 acquisitionrange <- 800:15000      ### obtained dirk eddelbuettel: https://stackoverflow.com/questions/14720983/efficiently-generate-a-random-sample-of-times-and-dates-between-two-dates generatedates <- function(n, st="2014/01/01", et="2015/08/31") { st <- as.posixct(as.date(st)) et <- as.posixct(as.date(et)) dt <- as.numeric(difftime(et,st,unit="sec")) ev <- sort(runif(n, 0, dt)) rt <- st + ev rt[order(rt)] as.date(rt) }   ## generate data; 10 readings each month out of 20 months datevalues <- generatedates(200) earnpts <- sample(x = earnptsrange, size = 190) earncount <- sample(x = earncountrange, size = 190) redempts <- sample(x = redemptsrange, size = 190) redemcount <- sample(x = redemcountrange, size = 190) churncount <- sample(x = churnrange, size = 190) acquiscount <- sample(x = acquisitionrange, size = 190) ## merge generated data toydata <- data.frame(datevalues = datevalues, earnpts = earnpts, earncount = earncount, redempts = redempts, redemcount = redemcount, churncount = churncount,  acquiscount = acquiscount)   ## write data csv file write.csv(x = toydata, file = './toydataset.csv', row.names = false) 

many in advance.

i have pushed think fix issue on fork of rcharts. solved issues responsiveness , auto-resizing rcharts. way use specifying width , height parameter in showoutput. default width 100% , default height 400px. example call showoutput("mygraph", "nvd3", height=555)

you can download from: https://github.com/clecocel/rcharts

and can install using: devtools::install_github("clecocel/rcharts")


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -