https://github.com/davzim/reactflow
https://github.com/davzim/reactflow
r react reactflow shiny
Last synced: 7 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/davzim/reactflow
- Owner: DavZim
- License: other
- Created: 2024-11-27T16:48:16.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-01-27T20:44:48.000Z (about 1 year ago)
- Last Synced: 2025-04-07T08:37:06.388Z (12 months ago)
- Topics: r, react, reactflow, shiny
- Language: R
- Homepage: https://davzim.github.io/reactflow/
- Size: 2.09 MB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- License: LICENSE
Awesome Lists containing this project
README
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# reactflow
An experimental R package to use [`@xyflow/react`](https://reactflow.dev) in R and shiny. Barely working at the moment!
# ToDos
[s] add MiniMap, Controls, Background functionality,
[ ] also ViewportLogger, NodeInspector, ChangeLogger, BaseEdge, ControlButton, EdgeLabelRenderer, EdgeText, Handle, NodeResizer, NodeResizeControl, NodeToolbar, Panel, ViewportPanel: https://reactflow.dev/api-reference/components
[ ] allow custom functions for onNodesChange, onEdgesChange, onConnect
[s] allow get ID from shiny (click function)
[s] fix reactive values to redraw layout https://reactflow.dev/api-reference/hooks/use-update-node-internals
[ ] setNodes/setEdges from R? also Getters?
[ ] examples, eg https://reactflow.dev/examples/interaction/interaction-props
[ ] edge label at end
Layout Examples
## Examples
```{r}
nodes <- list(
list(id = "s", type = "input", data = list(label = "Start"),
className = "startNode", position = list(x = 0, y = 0)),
list(id = "m", data = list(label = "Mid"), position = list(
x = 0, y = 100)),
list(id = "e", data = list(label = "End"),
className = "endNode", position = list(x = 50, y = 200),
type = "output")
)
edges <- list(
list(id = "s-m", source = "s", target = "m", type = "smoothstep", animated = TRUE),
list(id = "m-e", source = "m", target = "e", type = "smoothstep", animated = TRUE)
)
reactflow::reactflow(
nodes,
edges
)
```
## Development
Clone the repository
```r
system("yarn install")
system("yarn run webpack")
devtools::document()
devtools::install(quick = TRUE)
# or in one go:
# system("yarn install && yarn run webpack"); devtools::document(); devtools::install(quick=TRUE)
# start a shiny app that should display a flow
shiny::runApp()
```