Rshiny timevis和Shinytree Bug?与timevis一起使用时未渲染树

时间:2018-09-27 21:26:17

标签: r shiny

我是R和Shinystudio的新手,我正在尝试制定带有课程过滤器的议程。它已经可以与Vanilla复选框一起使用了,但是一棵树会更好。 当我不使用timevisoutputs时,树被渲染,添加时树消失了? Timevis输出在代码的底部 Timevis和Shinytree都是外部软件包,也许它们不能一起工作?

    library(shiny)
library(shinythemes)

groups <- data.frame(
  id = c("BOP", "probleem oplossend denken", "Netwerken 1"),
  content = c("BOP", "probleem oplossend denken", "Netwerken 1")
)

dataGroups <- data.frame(
  id = 1:9,
  content = c("Opdracht", "Opdracht",
              "Opdracht", "Opdracht", "Opdracht",
              "Opdracht", "Opdracht", "Opdracht", "Opdracht"),
  start = c("2018-05-01 07:30:00", "2018-05-01 14:00:00",
            "2018-05-01 06:00:00", "2018-05-01 14:00:00", "2018-05-01 08:00:00",
            "2018-05-01 08:00:00", "2018-05-01 08:30:00", "2018-05-01 14:00:00",
            "2018-05-01 16:00:00"
  ),
  end   = c("2018-05-01 12:00:00", "2018-05-01 20:00:00",
            "2018-05-01 12:00:00", "2018-05-01 22:00:00", "2018-05-01 10:00:00",
            "2018-05-01 08:30:00", "2018-05-01 12:00:00", "2018-05-01 16:00:00",
            "2018-05-01 20:00:00"
  ),
  group = c(rep("BOP", 2), rep("probleem oplossend denken", 3), rep("Netwerken 1", 4)),
  type = c(rep("range", 9))
)


data <- data.frame(
  id      = 1:4,
  content = c("Item one", "Item two",
              "Ranged item", "Item four"),
  start   = c("2016-01-10", "2016-01-11",
              "2016-01-20", "2016-02-14 15:00:00"),
  end     = c(NA, NA, "2016-02-04", NA)
)


server <- function(input, output, session) {
  output$timeline1 <- renderTimevis({
    timevis(data)
  })

  output$timeline2 <- renderTimevis({
    timevis(data = dataGroups, groups = data.frame( id = input$checkGroup, content= input$checkGroup), options = list(editable = TRUE))
  })

  output$tree <- renderTree({
    structure(
      list(
        'Fase 1' = structure(
          list(
            'OOP'=structure('',stid=1,stclass='study'), 
            'web1'=structure('',stid=2,stclass='study')
          ),
          stid=1,
          stopened=TRUE,
          stclass='project'
        ), 
        'Fase 2' = structure(
          list(
            'web2'=structure('',stid=3,stclass='study'), 
            'OOO'=structure('',stid=4,stclass='study')
          ),
          stid=2,
          stopened=TRUE,
          stclass='project'
        ), 
        'Fase 3' = structure(
          list(
            'pvm'=structure('',stid=3,stclass='study'), 
            'mobiele'=structure('',stid=4,stclass='study')
          ),
          stid=2,
          stopened=TRUE,
          stclass='project'
        )
      ),
      stopened=TRUE
    )
  })
}

ui <- fluidPage(theme=shinytheme("cerulean"),

                titlePanel("Use an existing theme"),

                sidebarLayout(

                  sidebarPanel(
                    h3("Note the button is black. This is different from the previous app."),
                    actionButton("button", "A button")
                  ), 

                  mainPanel(
                    tabsetPanel(
                      tabPanel("Plot"), 
                      tabPanel("Summary"), 
                      tabPanel("Table")
                    ),




                    fluidRow(

                      column(3,
                             shinyTree("tree", checkbox = TRUE,theme="proton")),
                      column(3,
                             checkboxGroupInput("checkGroup", label = h3("Checkbox group"), 
                                                choices = list("Netwerken 1" = "Netwerken 1", "Probleem oplossend denken" = "Probleem Oplossend denken", "BOP" = "BOP"),
                                                selected = "Netwerken 1"))


                    ),
                    fluidRow(

                      column(12,
                             textInput("text", h3("Text input"), 
                                       value = "Enter text..."))


                    ),
                    fluidRow(

                      column(12,
                             textInput("text", h3("Text input"), 
                                       value = "Enter text..."))


                    ),
                    fluidRow(

                      column(12,
                             timevisOutput("timeline1"))


                    ),
                    fluidRow(

                      column(12,
                             timevisOutput("timeline2"))


                    )


                  )
                )
)

shinyApp(ui = ui, server = server)

With timevisoutput

Without timevisoutput

提前谢谢! 卡尔文

0 个答案:

没有答案