如何在argonDash仪表板中使用模块

时间:2019-10-18 02:58:30

标签: r shiny

我刚刚发现了这些令人称奇的软件包argonR和argonDash,但是,不幸的是,到目前为止,我还没有成功使用它们的模块。有可能吗?

我尝试过ns,但是它不起作用。它可以在本地运行,但是部署后无法更改标签。


# rm(list = ls())

library(shiny)
library(shinydashboard)
library(argonR)
library(argonDash)
library(magrittr)
library(shinyjs)

# Modules
source("sidebar.R", encoding = "utf8")
source("navbar.R", encoding = "utf8")
source("header.R", encoding = "utf8")
source("footer.R", encoding = "utf8")
source("R/mod_home.R", encoding = "utf8")
source("R/mod_stats.R", encoding = "utf8")
source("R/mod_prob.R", encoding = "utf8")
source("R/mod_stat_econ.R", encoding = "utf8")
source("R/mod_econometria.R", encoding = "utf8")
source("R/mod_ML.R", encoding = "utf8")
source("R/mod_quiz.R", encoding = "utf8")
source("R/mod_sobre.R", encoding = "utf8")

# App
ui <- argonDashPage(
  title = "TCM",
  author = "Guilherme",
  description = "Guig's TCM",

  sidebar = argonDashSidebar(
    vertical = TRUE,
    skin = "light",
    background = "white",
    size = "md",
    side = "left",
    id = "my_sidebar",
    brand_url = "http://www.google.com",
    # brand_logo = "https://demos.creative-tim.com/argon-design-system/assets/img/brand/blue.png",
    # brand_logo = ,
    brand_logo = "https://kdrt.org/sites/default/files/styles/adaptive/public/Rocket%20Radio%20program%20picture.png?itok=-FHCim8R",

    argonSidebarHeader(title = "Menu Principal"),
    argonSidebarMenu(
      argonSidebarItem(
        tabName = "home_tab",
        style="text-align:center",
        "Home"
      ),
      argonSidebarItem(
        tabName = "stats_tab",
        style="text-align:center",
        "Estatística"
      ),
      argonSidebarItem(
        tabName = "prob_tab",
        style="text-align:center",
        "Probabilidade"
      ),
      argonSidebarItem(
        tabName = "stat_econ_tab",
        style="text-align:center",
        "Estatística Econômica"
      ),
      argonSidebarItem(
        tabName = "econometria_tab",
        style="text-align:center",
        "Econometria"
      ),
      argonSidebarItem(
        tabName = "ML_tab",
        style="text-align:center",
        "Machine Learning"
      ),
      argonSidebarItem(
        tabName = "quiz_tab",
        style="text-align:center",
        "Quiz"
      ),
      argonSidebarItem(
        tabName = "sobre_tab",
        style="text-align:center",
        "Sobre"
      )
    ),
    argonSidebarDivider(),
    argonSidebarHeader(title = "@TCM  Versão 0.1")
  ),

  navbar = argonDashNavbar(
    argonDropNav(
      title = "Powered by R",
      # src = "https://demos.creative-tim.com/argon-dashboard/assets/img/theme/team-4-800x800.jpg",
      src = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRCLcatfAURCtGHsd71IjruuQqMXjezkwwjZR5inocuNz0imUF5sA",
      orientation = "right",
      argonDropNavTitle(title = "Este app é formado por"),
      argonDropNavItem(
        title = "R",
        src = "https://www.r-project.org/",
        icon = argonIcon("single-02")
      ),
      argonDropNavItem(
        title = "RStudio",
        src = "https://rstudio.com/",
        icon = argonIcon("settings-gear-65")
      ),
      argonDropNavDivider(),
      argonDropNavItem(
        title = "Guigo's código",
        src = "#",
        icon = argonIcon("calendar-grid-58")
      )
    )
  ),

  header = argonDashHeader(
    gradient = TRUE,
    color = "primary",
    separator = TRUE,
    separator_color = "secondary"#,
    # argonCard(
    #   title = "Olá, visitante!",
    #   src = "https://www.linkedin.com/in/guilherme-viegas-1b5b0495/",
    #   hover_lift = TRUE,
    #   shadow = TRUE,
    #   shadow_size = NULL,
    #   hover_shadow = FALSE,
    #   border_level = 0,
    #   # icon = argonIcon("atom"),
    #   icon = "https://scontent.ffln1-1.fna.fbcdn.net/v/t1.0-9/13669798_1073355219425752_3359245208514920392_n.jpg?_nc_cat=111&_nc_oc=AQk0e2H7_Cjzdx97Vq_sl2v_JrdqSZBK5oFe6Kj6VGu_OKOvO7zFTwta02RVm-Bz8Ck&_nc_ht=scontent.ffln1-1.fna&oh=bad62632b291289b4338d3aec456cbe2&oe=5E2B61E2",
    #   status = "primary",
    #   background_color = NULL,
    #   gradient = FALSE, 
    #   floating = FALSE,
    #   "Seja muito bem vindo.\nEste é meu cartão, tome."
    # )
  ),

  body = argonDashBody(
    argonTabItems(

      argonTabItem(
        tabName = "home_tab",
        mod_home_ui("home_ui_1")
      ),

      argonTabItem(
        tabName = "stats_tab",
        mod_stats_ui("stats_ui_1")
      ),

      argonTabItem(
        tabName = "prob_tab",
        mod_prob_ui("prob_ui_1")
      ),

      argonTabItem(
        tabName = "stat_econ_tab",
        mod_stat_econ_ui("stat_econ_ui_1")
      ),

      argonTabItem(
        tabName = "econometria_tab",
        mod_econometria_ui("econometria_ui_1")
      ),

      argonTabItem(
        tabName = "ML_tab",
        mod_ML_ui("ML_ui_1")
      ),

      argonTabItem(
        tabName = "quiz_tab",
        mod_quiz_ui("quiz_ui_1")
      ),

      argonTabItem(
        tabName = "sobre_tab",
        mod_sobre_ui("sobre_ui_1")
      )

    )
  ),
  footer = argonDashFooter(
    copyrights = "@Guilherme Viegas, 2019",
    src = "https://www.linkedin.com/in/guilherme-viegas-1b5b0495/",
    argonFooterMenu(
      argonFooterItem("Linkedin", src = "https://www.linkedin.com/in/guilherme-viegas-1b5b0495/"),
      argonFooterItem("Github", src = "https://github.com/Gui-go"),
      argonFooterItem("Facebook", src = "https://www.facebook.com/guilherme.viegas.90"),
      argonFooterItem("Instagram", src = "https://demos.creative-tim.com/argon-design-system/index.html")
    )
  )

)

server <- function(input, output) {

  # observeEvent(input$my_sidebar, {
  #   if (input$my_sidebar != "sobre") { 
  #     updateTabItems(session, inputId = "tabs", selected = "quiz") 
  #   }
  # })

  callModule(mod_home_server, "home_ui_1")
  callModule(mod_stats_server, "stats_ui_1")
  callModule(mod_prob_server, "prob_ui_1")
  callModule(mod_stat_econ_server, "stat_econ_ui_1")
  callModule(mod_econometria_server, "econometria_ui_1")
  callModule(mod_ML_server, "ML_ui_1")
  callModule(mod_quiz_server, "quiz_ui_1")
  callModule(mod_sobre_server, "sobre_ui_1")
}

shinyApp(ui = ui, server = server)

尽管它在本地工作,但是当我部署它时,它简单地不能在线工作。换句话说,它在本地运行良好,但是一旦启用,它就不会更改选项卡。对吗?

1 个答案:

答案 0 :(得分:0)

我找到了答案。对于2019年10月,CRAN软件包版本不允许更改选项卡(这是一个错误)。此错误已在其Github软件包版本中得到纠正,并且很快也会在CRAN上进行。只是一个错误,发生了...