https://github.com/cynkra/g6R
htmlwidget for the G6 Graph Visualization Framework
https://github.com/cynkra/g6R
g6 graph htmlwidget network shiny
Last synced: 15 days ago
JSON representation
htmlwidget for the G6 Graph Visualization Framework
- Host: GitHub
- URL: https://github.com/cynkra/g6R
- Owner: cynkra
- License: other
- Created: 2025-05-09T13:43:03.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2026-03-19T06:50:31.000Z (21 days ago)
- Last Synced: 2026-03-19T09:50:14.975Z (21 days ago)
- Topics: g6, graph, htmlwidget, network, shiny
- Language: R
- Homepage: https://cynkra.github.io/g6R/
- Size: 121 MB
- Stars: 28
- Watchers: 3
- Forks: 3
- Open Issues: 10
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- License: LICENSE
Awesome Lists containing this project
- awesome-shiny-extensions - g6R - Graph visualization engine widget based on AntV G6 for R and Shiny. (Visualization / Network and Graph Data)
README
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# g6R
[](https://github.com/cynkra/g6R/actions/workflows/R-CMD-check.yaml)
[](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[](https://CRAN.R-project.org/package=g6R)
[](https://app.codecov.io/gh/cynkra/g6R)
{width="50%" alt="g6R hex logo"}
`{g6R}` provides R bindings to the G6 graph [library](https://g6.antv.antgroup.com/en). It allows to create interactive network in R, with stunning set of features, including:
- Support for various __layouts__, such as force-directed, radial, circular, and hierarchical layouts.
- Interactive __behaviors__ like zooming, dragging, and selecting elements.
- __Plugins__ for additional functionality, such as minimaps and tooltips, context menus, and node grouping features like bubble sets, hulls and legends.
- Various __data sources__ including data frames, lists and remote JSON urls.
- Support for __combos__ allowing for __nested__ nodes.
- High __performance__ rendering (>20000 nodes).
{width="50%" alt="g6R layers example"}
## Installation
You can install the development version of `{g6R}` from [GitHub](https://github.com/) with:
``` r
# install.packages("pak")
pak::pak("cynkra/g6R")
```
## Example
To create a `{g6R}` graph:
```r
library(g6R)
nodes <- data.frame(id = 1:10)
# Generate random edges
edges <- data.frame(
source = c(2, 6, 7),
target = c(1, 3, 9)
)
g6(nodes, edges) |>
g6_options(
node = list(
style = list(
labelBackground = TRUE,
labelBackgroundFill = '#FFB6C1',
labelBackgroundRadius = 4,
labelFontFamily = 'Arial',
labelPadding = c(0, 4),
labelText = JS(
"(d) => {
return d.id
}"
)
)
)
) |>
g6_layout(d3_force_layout()) |>
g6_behaviors(
"zoom-canvas",
drag_element_force(fixed = TRUE),
click_select(
multiple = TRUE,
onClick = JS(
"(e) => {
console.log(e);
}"
)
),
brush_select(),
create_edge()
) |>
g6_plugins(
"minimap",
"tooltip",
context_menu()
)
```