2
votes

I'd like to add some TileMaker elements in my shiny apps to make it a better dashboard (but I did not use shinydashboard structure). See the server.R and ui.R below for minimal example:

Server.R

library(shiny)
library(TileMaker)
shinyServer(function(input, output) {

Tilemaker<-renderPlot({

  Button1 <- ButtonMaker(Color = 2,Value = 3.57,Subtitle = "Times apple eaten")
  Button2 <- ButtonMaker(Color = 3,Value = 13.7,Subtitle = "Nutritional value")
  Button3 <- ButtonMaker(Color = 4,Value = 1,Subtitle = "Yumminess factor")
  Button4 <- ButtonMaker(Color = 5,Size=1,Value = 5,Subtitle = "Inconsistencies")
  Div1 <- DivMaker(Title = "Quantativity factors",Buttons = paste(Button1,Button2))
  Div2 <- DivMaker(Title = "Implementation procedures",Buttons = paste(Button3,Button4))
  TileMaker(MainTitle = "Hello",Divs = paste(Div1,Div2), FileName = "123.html")
  browseURL("123.html")
 })  
})

ui.R

library(shiny)
shinyUI(fluidPage(
mainPanel(
      navlistPanel(
    tabPanel("Tilemaker",h1("Tilemaker"),plotOutput(Tilemaker))
   )
  )
 ) 
)

I've searched for a while but no related discussion and I tried both renderplot and renderimage but both did not work. Is TilmeMaker another render type or it cannot be used in shiny app? Any advise is appreciated. Thanks.

1

1 Answers

1
votes

You need renderUI( if you want to create Tile on server side) and not need to save (as said in help

"If you would like just HTML code (suitable for inserting in a dashboard or another document, you can use the Divs"

)

Example

library(shiny)
library(TileMaker)
server=shinyServer(function(input, output) {

  output$Tilemaker<-renderUI({

    Button1 <- ButtonMaker(Color = 2,Value = 3.57,Subtitle = "Times apple eaten")
    Button2 <- ButtonMaker(Color = 3,Value = 13.7,Subtitle = "Nutritional value")
    Button3 <- ButtonMaker(Color = 4,Value = 1,Subtitle = "Yumminess factor")
    Button4 <- ButtonMaker(Color = 5,Size=1,Value = 5,Subtitle = "Inconsistencies")
    Div1 <- DivMaker(Title = "Quantativity factors",Buttons = paste(Button1,Button2))
    Div2 <- DivMaker(Title = "Implementation procedures",Buttons = paste(Button3,Button4))
    return( list(h1("Hello"),HTML(Div1,Div2)))
  })  
})

ui=shinyUI(fluidPage(
  mainPanel(
    navlistPanel(
      tabPanel("Tilemaker",h1("Tilemaker"),uiOutput("Tilemaker"))
    )
  )
) 
)

shinyApp(ui,server)