Skip to content

Commit

Permalink
feat: adds @cosmograph-org/cosmo GPU layout (#9)
Browse files Browse the repository at this point in the history
* 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")
  • Loading branch information
daniloimparato authored Oct 5, 2024
1 parent 205a395 commit 5ee6a4f
Show file tree
Hide file tree
Showing 21 changed files with 2,529 additions and 644 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.vscode

# Temp
inst/temp

Expand Down
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ Imports:
dplyr,
igraph,
jsonlite,
shiny
shiny,
tidyselect
Suggests:
testthat (>= 3.0.0)
Config/testthat/edition: 3
Expand Down
16 changes: 13 additions & 3 deletions R/app.R
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,19 @@ start_app <- function(graph, layout) {

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

selected_node_cols <- graph |>
igraph::as_data_frame("vertices") |>
dplyr::select(
id = name,
initialX = x,
initialY = y,
component,
tidyselect::any_of(c("color", "size"))
)

graph_json <- jsonlite::toJSON(list(
nodes = igraph::as_data_frame(graph, "vertices"),
links = igraph::as_data_frame(graph, "edges")
nodes = selected_node_cols,
links = igraph::as_data_frame(graph, "edges")[, 1:2]
))

server <- function(input, output, session) {
Expand Down Expand Up @@ -155,7 +165,7 @@ precompute_layout <- function(graph, cols) {

similarity_layout <- igraph::layout_with_fr(
graph = similarity_graph,
niter = 1000
niter = 500
) * LAYOUT_SIZE_FACTOR

# Centers layout around origin = [0, 0]
Expand Down
29 changes: 16 additions & 13 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,21 @@ knitr::opts_chunk$set(
[![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)
<!-- badges: end -->

easylayout is an R package that seamlessly bridges manipulation and
visualization by leveraging the user's IDE itself (e.g., RStudio, VSCode). It
is **not** yet another visualization library, but instead aims to interconnect
existing libraries and streamline their usage into the R ecosystem. easylayout
takes an igraph object and serializes it into a web application integrated with
the IDE's interface through a Shiny server. The web application lays out the
network by simulating attraction and repulsion forces. Simulation parameters
can be adjusted in real-time. An editing mode allows moving and rotating nodes.
The implementation aims for performance, so that even lower-end devices are
able to work with relatively large networks. Once the user finishes tinkering
the layout, it is sent back to the R session to be plotted through popular
libraries like ggplot2 or even the base package itself.
easylayout is an R package that leverages interactive force simulations within
the IDE itself (e.g., RStudio, VSCode). It is **not** yet another visualization
library, but instead aims to interconnect existing libraries and streamline
their usage into the R ecosystem.

![](https://github.com/user-attachments/assets/1b91cb11-77ef-47a5-b529-3805a9785a76)

easylayout takes an igraph object and serializes it into a web application
integrated with the IDE's interface through a Shiny server. The web application
lays out the network by simulating attraction and repulsion forces. Simulation
parameters can be adjusted in real-time. An editing mode allows moving and
rotating nodes. The implementation aims for performance, so that even lower-end
devices are able to work with relatively large networks. Once the user finishes
tinkering the layout, it is sent back to the R session to be plotted through
popular libraries like ggplot2 or even the base package itself.

## Installation

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

## Future work
Expand Down
31 changes: 17 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,22 @@
[![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)
<!-- badges: end -->

easylayout is an R package that seamlessly bridges manipulation and
visualization by leveraging the user’s IDE itself (e.g., RStudio,
VSCode). It is **not** yet another visualization library, but instead
aims to interconnect existing libraries and streamline their usage into
the R ecosystem. easylayout takes an igraph object and serializes it
into a web application integrated with the IDE’s interface through a
Shiny server. The web application lays out the network by simulating
attraction and repulsion forces. Simulation parameters can be adjusted
in real-time. An editing mode allows moving and rotating nodes. The
implementation aims for performance, so that even lower-end devices are
able to work with relatively large networks. Once the user finishes
tinkering the layout, it is sent back to the R session to be plotted
through popular libraries like ggplot2 or even the base package itself.
easylayout is an R package that leverages interactive force simulations
within the IDE itself (e.g., RStudio, VSCode). It is **not** yet another
visualization library, but instead aims to interconnect existing
libraries and streamline their usage into the R ecosystem.

![](https://github.com/user-attachments/assets/1b91cb11-77ef-47a5-b529-3805a9785a76)

easylayout takes an igraph object and serializes it into a web
application integrated with the IDE’s interface through a Shiny server.
The web application lays out the network by simulating attraction and
repulsion forces. Simulation parameters can be adjusted in real-time. An
editing mode allows moving and rotating nodes. The implementation aims
for performance, so that even lower-end devices are able to work with
relatively large networks. Once the user finishes tinkering the layout,
it is sent back to the R session to be plotted through popular libraries
like ggplot2 or even the base package itself.

## Installation

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

plot(g, layout = easylayout)
plot(g, layout = easylayout, vertex.label = NA, margin = 0)
```

## Future work
Expand Down
2 changes: 1 addition & 1 deletion inst/www/assets/index.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions inst/www/browser.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5ee6a4f

Please sign in to comment.