Skip to content

Commit 011fba7

Browse files
authored
Merge pull request #24 from cynkra/23-add-plugin-patch
fix #23
2 parents 9b1f12e + e0aaf5c commit 011fba7

File tree

13 files changed

+62
-43
lines changed

13 files changed

+62
-43
lines changed

CRAN-SUBMISSION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
Version: 0.1.0
2-
Date: 2025-07-03 09:32:36 UTC
3-
SHA: 3da178dd8286995549966ed1af73341a4f80e748
2+
Date: 2025-07-07 14:24:39 UTC
3+
SHA: 32a0bdfc931ad9d339a8e33d92920f8b63515cd4

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: g6R
22
Title: Graph Visualisation Engine Widget for R and 'shiny' Apps
3-
Version: 0.1.1
3+
Version: 0.2.0
44
Authors@R:
55
c(
66
person("David", "Granjon", , "[email protected]", role = c("aut", "cre")),

NEWS.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
# g6R 0.1.1
1+
# g6R 0.2.0
22

3-
- Fix internal typo in JS function when an error was caught in the graph.
3+
- Fix [#23](<https://github.com/cynkra/g6R/issues/23>): graph has to be re-rendered after dynamic plugin addition so that new elements like `hull` are drawn.
4+
- Fix [#22](<https://github.com/cynkra/g6R/issues/22>): internal typo in JS function when an error was caught in the graph.
45
- Add `input$<graph_ID>-contextmenu` to extract the type and id of element which was clicked in the context menu.
56
This can be listened to from the Shiny server function.
67

R/plugins.R

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,9 @@ background <- function(
193193
#' Creates a configuration object for the bubble-sets plugin in G6.
194194
#' This plugin creates bubble-like contours around groups of specified elements.
195195
#'
196-
#' @param members Member elements, including nodes and edges (character vector, required).
196+
#' @param members Member elements, including nodes and edges (character/numeric vector, required).
197197
#' @param key Unique identifier for updates (string, default: NULL).
198-
#' @param avoidMembers Elements to avoid when drawing contours (character vector, default: NULL).
198+
#' @param avoidMembers Elements to avoid when drawing contours (character/numeric vector, default: NULL).
199199
#' @param label Whether to display labels (boolean, default: TRUE).
200200
#' @param labelPlacement Label position (string, default: "bottom").
201201
#' @param labelBackground Whether to display background (boolean, default: FALSE).
@@ -281,13 +281,27 @@ bubble_sets <- function(
281281
virtualEdges = NULL,
282282
...
283283
) {
284-
# TBD: validate members to it validate real node ids who exist.
285284
if (label) {
286285
labelPlacement <- match.arg(labelPlacement)
287286
}
288287
# Check for required parameters
289-
if (missing(members) || is.null(members) || length(members) == 0) {
290-
stop("'members' is required and must contain at least one element ID")
288+
if (!is.character(members) && !is.numeric(members) || length(members) == 0) {
289+
stop("'members' must be a non-empty character/numeric vector")
290+
}
291+
292+
members <- as.character(members)
293+
294+
if (
295+
!is.null(avoidMembers) &&
296+
(!is.character(avoidMembers) &&
297+
!is.numeric(avoidMembers) ||
298+
length(avoidMembers) == 0)
299+
) {
300+
stop("'avoidMembers' must be a character/numeric vector or NULL")
301+
}
302+
303+
if (!is.null(avoidMembers)) {
304+
avoidMembers <- as.character(avoidMembers)
291305
}
292306

293307
# Get argument names
@@ -1095,7 +1109,7 @@ history <- function(
10951109
#' Creates a configuration object for the hull plugin in G6.
10961110
#' This plugin creates a hull (convex or concave) that surrounds specified graph elements.
10971111
#'
1098-
#' @param members Elements within the hull, including nodes and edges (character vector, required).
1112+
#' @param members Elements within the hull, including nodes and edges (character/numeric vector, required).
10991113
#' @param key Unique identifier for the plugin (string, default: NULL).
11001114
#' @param concavity Concavity parameter, larger values create less concave hulls (number, default: Infinity).
11011115
#' @param corner Corner type: "rounded", "smooth", or "sharp" (string, default: "rounded").
@@ -1153,9 +1167,10 @@ hull <- function(
11531167
...
11541168
) {
11551169
# Validate inputs
1156-
if (!is.character(members) || length(members) == 0) {
1157-
stop("'members' must be a non-empty character vector")
1170+
if (!is.character(members) && !is.numeric(members) || length(members) == 0) {
1171+
stop("'members' must be a non-empty character/numeric vector")
11581172
}
1173+
members <- as.character(members)
11591174

11601175
if (!is.numeric(concavity) || concavity <= 0) {
11611176
stop("'concavity' must be a positive number or Infinity")

inst/examples/dataframe/app.R

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ server <- function(input, output, session) {
5151
)
5252
)
5353
) |>
54-
g6_layout(
55-
layout = d3_force_layout()
56-
) |>
54+
g6_layout() |>
5755
g6_behaviors(
5856
"zoom-canvas",
5957
drag_element_force(fixed = TRUE),
@@ -63,7 +61,6 @@ server <- function(input, output, session) {
6361
) |>
6462
g6_plugins(
6563
"minimap",
66-
"tooltip",
6764
context_menu()
6865
)
6966
})
@@ -72,9 +69,9 @@ server <- function(input, output, session) {
7269
g6_proxy("graph") |>
7370
g6_add_plugin(
7471
hull(
72+
members = sample(nodes$id, 10),
7573
fill = "#F08F56",
7674
stroke = "#F08F56",
77-
members = sample(nodes$id, 10),
7875
labelText = "hull-a",
7976
labelPlacement = "top",
8077
labelBackground = TRUE,

inst/htmlwidgets/g6.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/bubble_sets.Rd

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/hull.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@
2121
"dependencies": {
2222
"@antv/g": "^6.1.24",
2323
"@antv/g-svg": "^2.0.38",
24-
"@antv/g6": "^5.0.45"
24+
"@antv/g6": "^5.0.49"
2525
}
2626
}

0 commit comments

Comments
 (0)