using splitLayout with uiOutput

306 views
Skip to first unread message

msquatrito

unread,
Aug 5, 2014, 12:42:34 PM8/5/14
to shiny-...@googlegroups.com
Hi all,

In my shiny app I'm trying to put side by side multiple pie charts generated with rCharts (thanks to a previous post on this discussion group). I've tried to put the uiOutput inside a splitLayout(), but it does not work and the plots still appear in a vertical layout.
I guess it's an issue on how the various charts are generated, but I could not figure out how to solve it. 

Has anybody tried to combine an rCharts uiOutput with splitLayout?

This is the code I am using now :

library(shiny)
library
(rCharts)


runApp
(list(
  ui
= fluidPage(
    fluidRow
(
      splitLayout
(
        uiOutput
("piePlots")
     
)
   
)
 
),
 
  server
= function(input, output) {
   
#' Generate a graphic summary of the dataset, using rCharts
    output$piePlots
<- renderUI({
      data
<- data.frame (varX=c("a","a","b"), varY = c("c","d","c"))
      plot_output_list
<- lapply(names(data), function(i) {
        plotname
<- paste("plot", i, sep="")
        chartOutput
(plotname, "highcharts")
     
})
     
# Convert the list to a tagList - this is necessary for the list of items
     
# to display properly.
     
do.call(tagList, plot_output_list)
   
})
   
    observe
({                                                              
      data
<- data.frame (varX=c("a","a","b"), varY = c("c","d","c"))
     
# Call renderChart for each one.
     
for (i in names(data)) {                                                    
       
# Need local so that each item gets its own name. Without it, the value
       
# of i in the renderChart2() will be the same across all instances, because
       
# of when the expression is evaluated.
       
local({
          my_i
<-i
          plotname
<- paste("plot", my_i, sep="")
          output
[[plotname]] <- renderChart2({
            plotData
<- data.frame(table(data[, my_i]))
            hPlot
(x = "Var1", y = "Freq", data = plotData, type = "pie", title = my_i)
         
})
       
})
     
}
   
})
   
 
}
))

Thanks in advance!!
Best,
Massimo

 

stcallen

unread,
Feb 2, 2017, 7:13:08 PM2/2/17
to Shiny - Web Framework for R
Hi Massimo,

I know this post was from several years ago, but I was wondering if you found a solution. I have the same issue with using splitLayout to display a UI output. It would be great if you could update this with your solution, if you found one.

Kind regards,
Steven

Joe Cheng

unread,
Feb 3, 2017, 6:56:26 PM2/3/17
to stcallen, Shiny - Web Framework for R
The splitLayout should probably be used inside the renderUI, not around the uiOutput. Maybe try replacing the do.call(tagList with do.call(splitLayout?
--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/4abf09a1-32aa-42b6-9111-b2403d2f2f8e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Wilbert Heeringa

unread,
Nov 29, 2017, 2:01:21 PM11/29/17
to Shiny - Web Framework for R
tagList(splitLayout ... in renderUI ?
Reply all
Reply to author
Forward
0 new messages