rstudio / shinydashboard

Shiny Dashboarding framework
https://rstudio.github.io/shinydashboard/
Other
887 stars 299 forks source link

Fontawesome icons in visNetwork graph do not render in shinydashboard app #307

Closed redstplr closed 5 years ago

redstplr commented 5 years ago

Example

library(shinydashboard) library(visNetwork) library(magrittr) library(shiny)

Build a shinydashboard UI

header <- dashboardHeader(title = "visNetwork Graph")

sidebar <- dashboardSidebar( sidebarMenu( menuItem("visNetwork", tabName = "graph", icon = NULL) ) )

body <- dashboardBody( tabItems( tabItem(tabName = "graph", fluidPage( visNetworkOutput("le_graph", width = "100%", height = "600px") ) ) ) )

dashboardUI <- dashboardPage(header, sidebar, body, skin = "red")

Build a standard shiny UI

shinyUI <- fluidPage( visNetworkOutput("le_graph", width = "100%", height = "600px") ) )

Application server

SERVER <- function(input, output) { output$le_graph <- renderVisNetwork({ nodes <- data.frame(id = 1:3, group = c("B", "A", "B")) edges <- data.frame(from = c(1,2), to = c(2,3))

visNetwork(nodes = nodes, edges = edges, main = "Attack Paths",
          width = "100%", height = "600px") %>%
  visEdges(arrows = "to") %>%
  visGroups(groupname = "A", shape = "icon", 
            icon = list(code = "f007", size = 75)) %>%
  visGroups(groupname = "B", shape = "icon", 
            icon = list(code = "f0c0", color = "#f46d43")) %>%
  addFontAwesome() %>% 
  visIgraphLayout() %>%
  visOptions(manipulation = TRUE, nodesIdSelection = TRUE,
             highlightNearest = list(enabled = T, degree = 2, hover = T))

}) }

Application

dashboardapp <- shinyApp(ui = dashboardUI, server = SERVER) shinyapp <- shinyApp(ui = shinyUI, server = SERVER)

Fontawesome icons do not render in the shinydashboard application

runApp(dashboardapp) # does not work runApp(shinyapp) # does work

redstplr commented 5 years ago

Solution: https://github.com/datastorm-open/visNetwork/issues/292