Skip to content

Commit 5ee6a4f

Browse files
feat: adds @cosmograph-org/cosmo GPU layout (#9)
* docs: removes solved todo * chore: ignoring .vscode * wip: implements simulation wrapper to include cosmo * feat: introduces cosmo through unified wrapper interface * docs: adds screenshot to readme * fix: fixes the worst typo of my life * docs: idk where this came from * refactor: removes logging from editor * refactor: editor pans instead of zooming when centering canvas * refactor: rewrites layout effectors for d3 * refactor: giving up on centering viva for now * refactor: lowers number of iterations for fr precomputation * refactor: rewrites and reformats settings file * feat: overhauls cosmo's size and coordinate system * refactor: gets rid of flowbite-svelte range * fix: allows vertical scrolling for sidebar * fix: slider input was string * wip: attempting to remove cosmo's labels * feat: bumps alpha after updating layout parameter * feat: introduces all of d3 and cosmo forces * docs: removes img alt text * build: bump dist * build: usethis::use_package("tidyselect")
1 parent 205a395 commit 5ee6a4f

21 files changed

+2529
-644
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.vscode
2+
13
# Temp
24
inst/temp
35

DESCRIPTION

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ Imports:
1414
dplyr,
1515
igraph,
1616
jsonlite,
17-
shiny
17+
shiny,
18+
tidyselect
1819
Suggests:
1920
testthat (>= 3.0.0)
2021
Config/testthat/edition: 3

R/app.R

+13-3
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,19 @@ start_app <- function(graph, layout) {
9191

9292
igraph::V(graph)$component <- flag_for_grouping
9393

94+
selected_node_cols <- graph |>
95+
igraph::as_data_frame("vertices") |>
96+
dplyr::select(
97+
id = name,
98+
initialX = x,
99+
initialY = y,
100+
component,
101+
tidyselect::any_of(c("color", "size"))
102+
)
103+
94104
graph_json <- jsonlite::toJSON(list(
95-
nodes = igraph::as_data_frame(graph, "vertices"),
96-
links = igraph::as_data_frame(graph, "edges")
105+
nodes = selected_node_cols,
106+
links = igraph::as_data_frame(graph, "edges")[, 1:2]
97107
))
98108

99109
server <- function(input, output, session) {
@@ -155,7 +165,7 @@ precompute_layout <- function(graph, cols) {
155165

156166
similarity_layout <- igraph::layout_with_fr(
157167
graph = similarity_graph,
158-
niter = 1000
168+
niter = 500
159169
) * LAYOUT_SIZE_FACTOR
160170

161171
# Centers layout around origin = [0, 0]

README.Rmd

+16-13
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,21 @@ knitr::opts_chunk$set(
1919
[![R-CMD-check](https://github.com/dalmolingroup/easylayout/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/dalmolingroup/easylayout/actions/workflows/R-CMD-check.yaml)
2020
<!-- badges: end -->
2121

22-
easylayout is an R package that seamlessly bridges manipulation and
23-
visualization by leveraging the user's IDE itself (e.g., RStudio, VSCode). It
24-
is **not** yet another visualization library, but instead aims to interconnect
25-
existing libraries and streamline their usage into the R ecosystem. easylayout
26-
takes an igraph object and serializes it into a web application integrated with
27-
the IDE's interface through a Shiny server. The web application lays out the
28-
network by simulating attraction and repulsion forces. Simulation parameters
29-
can be adjusted in real-time. An editing mode allows moving and rotating nodes.
30-
The implementation aims for performance, so that even lower-end devices are
31-
able to work with relatively large networks. Once the user finishes tinkering
32-
the layout, it is sent back to the R session to be plotted through popular
33-
libraries like ggplot2 or even the base package itself.
22+
easylayout is an R package that leverages interactive force simulations within
23+
the IDE itself (e.g., RStudio, VSCode). It is **not** yet another visualization
24+
library, but instead aims to interconnect existing libraries and streamline
25+
their usage into the R ecosystem.
26+
27+
![](https://github.com/user-attachments/assets/1b91cb11-77ef-47a5-b529-3805a9785a76)
28+
29+
easylayout takes an igraph object and serializes it into a web application
30+
integrated with the IDE's interface through a Shiny server. The web application
31+
lays out the network by simulating attraction and repulsion forces. Simulation
32+
parameters can be adjusted in real-time. An editing mode allows moving and
33+
rotating nodes. The implementation aims for performance, so that even lower-end
34+
devices are able to work with relatively large networks. Once the user finishes
35+
tinkering the layout, it is sent back to the R session to be plotted through
36+
popular libraries like ggplot2 or even the base package itself.
3437

3538
## Installation
3639

@@ -57,7 +60,7 @@ igraph::V(g)$label <- NA
5760
igraph::V(g)$size <- sample(1:5, number_of_vertices, replace = TRUE)
5861
igraph::V(g)$color <- sample(rainbow(5), number_of_vertices, replace = TRUE)
5962
60-
plot(g, layout = easylayout)
63+
plot(g, layout = easylayout, vertex.label = NA, margin = 0)
6164
```
6265

6366
## Future work

README.md

+17-14
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,22 @@
88
[![R-CMD-check](https://github.com/dalmolingroup/easylayout/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/dalmolingroup/easylayout/actions/workflows/R-CMD-check.yaml)
99
<!-- badges: end -->
1010

11-
easylayout is an R package that seamlessly bridges manipulation and
12-
visualization by leveraging the user’s IDE itself (e.g., RStudio,
13-
VSCode). It is **not** yet another visualization library, but instead
14-
aims to interconnect existing libraries and streamline their usage into
15-
the R ecosystem. easylayout takes an igraph object and serializes it
16-
into a web application integrated with the IDE’s interface through a
17-
Shiny server. The web application lays out the network by simulating
18-
attraction and repulsion forces. Simulation parameters can be adjusted
19-
in real-time. An editing mode allows moving and rotating nodes. The
20-
implementation aims for performance, so that even lower-end devices are
21-
able to work with relatively large networks. Once the user finishes
22-
tinkering the layout, it is sent back to the R session to be plotted
23-
through popular libraries like ggplot2 or even the base package itself.
11+
easylayout is an R package that leverages interactive force simulations
12+
within the IDE itself (e.g., RStudio, VSCode). It is **not** yet another
13+
visualization library, but instead aims to interconnect existing
14+
libraries and streamline their usage into the R ecosystem.
15+
16+
![](https://github.com/user-attachments/assets/1b91cb11-77ef-47a5-b529-3805a9785a76)
17+
18+
easylayout takes an igraph object and serializes it into a web
19+
application integrated with the IDE’s interface through a Shiny server.
20+
The web application lays out the network by simulating attraction and
21+
repulsion forces. Simulation parameters can be adjusted in real-time. An
22+
editing mode allows moving and rotating nodes. The implementation aims
23+
for performance, so that even lower-end devices are able to work with
24+
relatively large networks. Once the user finishes tinkering the layout,
25+
it is sent back to the R session to be plotted through popular libraries
26+
like ggplot2 or even the base package itself.
2427

2528
## Installation
2629

@@ -48,7 +51,7 @@ igraph::V(g)$label <- NA
4851
igraph::V(g)$size <- sample(1:5, number_of_vertices, replace = TRUE)
4952
igraph::V(g)$color <- sample(rainbow(5), number_of_vertices, replace = TRUE)
5053

51-
plot(g, layout = easylayout)
54+
plot(g, layout = easylayout, vertex.label = NA, margin = 0)
5255
```
5356

5457
## Future work

inst/www/assets/index.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

inst/www/browser.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)