hzi-braunschweig / SORMAS-Stats-next-gen

SORMAS-Stats contain functions to analyze and visualize surveillance data collected by SORMAS.
GNU General Public License v3.0
4 stars 6 forks source link

Network icons are not are not well mapped #147

Closed bernardsilenou closed 2 years ago

bernardsilenou commented 2 years ago

Bug Description

The font awesome icons of the network diagram are not correctly mapped on demo servers.

Steps to Reproduce

  1. Connect to https://infra-sormas-stats.sormas.netzlink.com/sormas-stats-shinyapp/
  2. Visualize network diagram

Expected Behavior

Screenshots

Current image

Expected image

System Details

Additional Information

This is the function that plots the diagram https://github.com/hzi-braunschweig/SORMAS-Stats-next-gen/blob/development/sormas-stats-shinyapp/sormas-stats-app/utils_source_code/plotNet.R

jwijffels commented 2 years ago

Looks like this is caused by addFontAwesome If I do locally

library(visNetwork)
nodes <- data.frame(id = 1:3, group = c("B", "A", "B"))
edges <- data.frame(from = c(1,2), to = c(2,3))
visNetwork(nodes, edges) %>%
    visGroups(groupname = "A", shape = "icon", icon = list(code = "f0c0", size = 75)) %>%
    visGroups(groupname = "B", shape = "icon", icon = list(code = "f007", color = "red"))

image

visNetwork(nodes, edges) %>%
    visGroups(groupname = "A", shape = "icon", icon = list(code = "f0c0", size = 75)) %>%
    visGroups(groupname = "B", shape = "icon", icon = list(code = "f007", color = "red")) %>%
    addFontAwesome()

image

If I look to the relevant parts, I see

If I run the following on locally, shiny uses fontawesome 5.15.3

> str(shiny::icon(name = "play"))
List of 3
 $ name    : chr "i"
 $ attribs :List of 3
  ..$ class     : chr "fa fa-play"
  ..$ role      : chr "presentation"
  ..$ aria-label: chr "play icon"
 $ children: list()
 - attr(*, "class")= chr "shiny.tag"
 - attr(*, "html_dependencies")=List of 1
  ..$ :List of 10
  .. ..$ name      : chr "font-awesome"
  .. ..$ version   : chr "5.15.3"
  .. ..$ src       :List of 1
  .. .. ..$ file: chr "fontawesome"
  .. ..$ meta      : NULL
  .. ..$ script    : NULL
  .. ..$ stylesheet: chr [1:2] "css/all.min.css" "css/v4-shims.min.css"
  .. ..$ head      : NULL
  .. ..$ attachment: NULL
  .. ..$ package   : chr "fontawesome"
  .. ..$ all_files : logi TRUE
  .. ..- attr(*, "class")= chr "html_dependency"
 - attr(*, "browsable_html")= logi TRUE
jwijffels commented 2 years ago

I tried to change calls to addFontAwesome to addFontAwesome(version = "5.13.0") on https://infra-sormas-stats.sormas.netzlink.com but that did not work

jwijffels commented 2 years ago

Ok, found the solution, as addFontAwesome had argument name with as default name = 'font-awesome' and this put the fontawesome of visNetwork as htmldependency, that conflicted with shiny which uses the same name to register font-awesome. We just need to change the calls to addFontAwesome by providing another name e.g.: addFontAwesome(name = "sormas-fontawesome") Tested this on https://infra-sormas-stats.sormas.netzlink.com/sormas-stats-shinyapp/ image

bernardsilenou commented 2 years ago

@jwijffels Thanks, I would incorporate the change