-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
Hey!
Loving this new package that I feel is way more expressive and easier to configure than visNetwork that I've used the most.
However, when I want to change the underlying data in a shiny application to update the output, I noticed that the output gets stacked on the first output. I'm guessing this has to do with the htmlwidgets.
Here's a reproducible example:
library(shiny)
library(g6R)
# Module UI
network_ui <- function(id) {
ns <- NS(id)
tagList(
checkboxInput(ns("filter"), "Filter Network", value = FALSE),
g6Output(ns("network"), height = "400px")
)
}
# Module Server
network_server <- function(id) {
moduleServer(id, function(input, output, session) {
get_network_data <- reactive({
if (input$filter) {
nodes <- data.frame(id = 1:5, label = paste("Node", 1:5))
edges <- data.frame(source = c(1, 2, 3, 4), target = c(2, 3, 4, 5))
} else {
nodes <- data.frame(id = 1:10, label = paste("Node", 1:10))
edges <- data.frame(source = c(1, 2, 3), target = c(2, 3, 4))
}
list(nodes = nodes, edges = edges)
})
output$network <- renderG6({
data <- get_network_data()
g6(data$nodes, data$edges) |>
g6_layout(d3_force_layout())
})
})
}
ui <- fluidPage(network_ui("my_network"))
server <- function(input, output, session) {
network_server("my_network")
}
shinyApp(ui, server)The solution I found was to render the graph with renderUI and add dependency to the switch:
output$network_container <- renderUI({
input$filter
g6Output(ns("network"), height = "400px")
})Is this behavior expected? The problem arose when I tried to use g6 to replace a network in an app written with visNetwork.
Session info
> sessioninfo::session_info()
─ Session info ─────────────────────────────────────────────────────────────────────────────────────────────
setting value
version R version 4.5.1 (2025-06-13)
os Ubuntu 24.04.2 LTS
system x86_64, linux-gnu
ui RStudio
language (EN)
collate sv_SE.UTF-8
ctype sv_SE.UTF-8
tz Europe/Stockholm
date 2025-10-06
rstudio 2025.05.1+513 Mariposa Orchid (server)
pandoc 3.7.0.2 @ /usr/bin/pandoc
quarto 1.7.32 @ /usr/local/bin/quarto
─ Packages ─────────────────────────────────────────────────────────────────────────────────────────────────
! package * version date (UTC) lib source
P blob 1.2.4 2023-03-17 [?] RSPM (R 4.5.0)
P box 1.2.0 2024-02-06 [?] RSPM
P box.linters 0.10.5 2024-09-10 [?] RSPM
P box.lsp 0.1.3 2024-09-19 [?] RSPM
P bsicons 0.1.2 2023-11-04 [?] RSPM (R 4.5.0)
P bslib 0.9.0 2025-01-30 [?] RSPM
P cachem 1.1.0 2024-05-16 [?] RSPM
P class 7.3-23 2025-01-01 [?] CRAN (R 4.5.1)
P classInt 0.4-11 2025-01-08 [?] RSPM (R 4.5.0)
P cli 3.6.3 2024-06-21 [?] RSPM (R 4.5.0)
P config 0.3.2 2023-08-30 [?] RSPM
P crosstalk 1.2.1 2023-11-23 [?] RSPM (R 4.5.0)
P curl 6.2.2 2025-03-24 [?] RSPM (R 4.5.0)
P DBI 1.2.3 2024-06-02 [?] RSPM (R 4.5.0)
P dbplyr 2.5.1 2025-09-10 [?] RSPM
P digest 0.6.37 2024-08-19 [?] RSPM
P dplyr 1.1.4 2023-11-17 [?] RSPM (R 4.5.0)
P duckdb 1.4.0 2025-09-18 [?] RSPM
P e1071 1.7-16 2024-09-16 [?] RSPM (R 4.5.0)
P evaluate 1.0.3 2025-01-10 [?] RSPM
P farver 2.1.2 2024-05-13 [?] RSPM (R 4.5.0)
P fastmap 1.2.0 2024-05-15 [?] RSPM
P fontawesome 0.5.3 2024-11-16 [?] RSPM
P fs 1.6.5 2024-10-30 [?] RSPM (R 4.5.0)
P g6R * 0.1.0 2025-07-10 [?] RSPM
P generics 0.1.4 2025-05-09 [?] RSPM (R 4.5.0)
P glue 1.8.0 2024-09-30 [?] RSPM
P hms 1.1.3 2023-03-21 [?] RSPM (R 4.5.0)
P htmltools 0.5.8.1 2024-04-04 [?] RSPM
P htmlwidgets 1.6.4 2023-12-06 [?] RSPM (R 4.5.0)
P httpuv 1.6.15 2024-03-26 [?] RSPM (R 4.5.0)
P httr2 1.1.2 2025-03-26 [?] RSPM (R 4.5.0)
P jquerylib 0.1.4 2021-04-26 [?] RSPM
P jsonlite 1.8.9 2024-09-20 [?] RSPM (R 4.5.0)
P KernSmooth 2.23-26 2025-01-01 [?] CRAN (R 4.5.1)
P knitr 1.49 2024-11-08 [?] RSPM (R 4.5.0)
P later 1.4.1 2024-11-27 [?] RSPM (R 4.5.0)
P leaflet 2.2.3 2025-09-04 [?] RSPM
P lifecycle 1.0.4 2023-11-07 [?] RSPM
P logger 0.3.0 2024-03-05 [?] RSPM (R 4.5.0)
P lubridate 1.9.4 2024-12-08 [?] RSPM (R 4.5.0)
P magrittr 2.0.3 2022-03-30 [?] RSPM
P memoise 2.0.1 2021-11-26 [?] RSPM
P mime 0.12 2021-09-28 [?] RSPM (R 4.5.0)
P pillar 1.10.2 2025-04-05 [?] RSPM (R 4.5.0)
P pkgconfig 2.0.3 2019-09-22 [?] RSPM (R 4.5.0)
P promises 1.3.2 2024-11-28 [?] RSPM (R 4.5.0)
P proxy 0.4-27 2022-06-09 [?] RSPM (R 4.5.0)
P purrr 1.1.0 2025-07-10 [?] RSPM
P R6 2.5.1 2021-08-19 [?] RSPM (R 4.5.0)
P rappdirs 0.3.3 2021-01-31 [?] RSPM
P RColorBrewer 1.1-3 2022-04-03 [?] RSPM (R 4.5.0)
P Rcpp 1.0.13-1 2024-11-02 [?] RSPM (R 4.5.0)
P reactable 0.4.4 2023-03-12 [?] RSPM (R 4.5.0)
P reactR 0.6.1 2024-09-14 [?] RSPM (R 4.5.0)
P readr 2.1.5 2024-01-10 [?] RSPM (R 4.5.0)
renv 1.0.11 2024-10-12 [1] RSPM (R 4.5.1)
P rhino 1.11.0 2025-04-02 [?] RSPM
P rlang 1.1.6 2025-04-11 [?] RSPM
P rstudioapi 0.17.1 2024-10-22 [?] RSPM
P sass 0.4.9 2024-03-15 [?] RSPM (R 4.5.0)
P scales 1.4.0 2025-04-24 [?] RSPM (R 4.5.0)
P sessioninfo 1.2.3 2025-02-05 [?] RSPM (R 4.5.0)
P sf 1.0-20 2025-03-24 [?] RSPM (R 4.5.0)
P shiny * 1.11.1 2025-07-03 [?] RSPM
P shinycssloaders 1.1.0 2024-07-30 [?] RSPM (R 4.5.0)
P shinyjs 2.1.0 2021-12-23 [?] RSPM (R 4.5.0)
P stringi 1.8.4 2024-05-06 [?] RSPM (R 4.5.0)
P stringr 1.5.2 2025-09-08 [?] RSPM
P tibble 3.2.1 2023-03-20 [?] RSPM (R 4.5.0)
P tidyr 1.3.1 2024-01-24 [?] RSPM (R 4.5.0)
P tidyselect 1.2.1 2024-03-11 [?] RSPM (R 4.5.0)
P timechange 0.3.0 2024-01-18 [?] RSPM (R 4.5.0)
P timevis 2.1.0 2022-11-03 [?] RSPM (R 4.5.0)
P tzdb 0.5.0 2025-03-15 [?] RSPM (R 4.5.0)
P units 0.8-7 2025-03-11 [?] RSPM (R 4.5.0)
P vctrs 0.6.5 2023-12-01 [?] RSPM
P visNetwork 2.1.4 2025-09-04 [?] RSPM
P withr 3.0.2 2024-10-28 [?] RSPM
P xfun 0.50 2025-01-07 [?] RSPM (R 4.5.0)
P xtable 1.8-4 2019-04-21 [?] RSPM
P yaml 2.3.10 2024-07-26 [?] RSPM
[1] /home/user/app/renv/library/linux-ubuntu-noble/R-4.5/x86_64-pc-linux-gnu
[2] /home/user/.cache/R/renv/sandbox/linux-ubuntu-noble/R-4.5/x86_64-pc-linux-gnu/25ebdc09
* ── Packages attached to the search path.
P ── Loaded and on-disk path mismatch.
────────────────────────────────────────────────────────────────────────────────────────────────────────────
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels