Title: | Circle Plot with Bundled Edges |
---|---|
Description: | Generates interactive circle plots with the nodes around the circumference and linkages between the connected nodes using hierarchical edge bundling via the D3 JavaScript library. See <http://d3js.org/> for more information on D3. |
Authors: | Garth Tarr [aut, cre], Mike Bostock [aut, cph] (d3.js library and much of edgebundle code in htmlwidgets/lib, http://d3js.org), Ellis Patrick [aut], Kent Russell [ctb] |
Maintainer: | Garth Tarr <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.1.5 |
Built: | 2024-10-29 03:00:51 UTC |
Source: | https://github.com/garthtarr/edgebundler |
Helper function to convert adjacency matrix to edges
adjToEdge(adj)
adjToEdge(adj)
adj |
an adjacency matrix |
Takes an appropriately structured JSON file or a square symmetric matrix (e.g. a correlation matrix or precision matrix) and outputs a circle plot with the nodes around the circumfrence and linkages between the connected nodes. Adapted from the Mike Bostock's D3 Hierarchical Edge Bundling example using the htmlwidgets framework.
edgebundle(x, tension = 0.5, cutoff = 0.1, width = NULL, fontsize = 14, padding = 100, nodesize = c(5, 20), directed = FALSE)
edgebundle(x, tension = 0.5, cutoff = 0.1, width = NULL, fontsize = 14, padding = 100, nodesize = c(5, 20), directed = FALSE)
x |
an appropriately structured JSON file (see vignette for details) or a square symmetric matrix (e.g. correlation matrix) or an igraph object. |
tension |
numeric between 0 and 1 giving the tension of the links |
cutoff |
numeric giving the threshold dependence for linkages to be plotted |
width |
the width of the plot when viewed externally |
fontsize |
font size of the node labels |
padding |
the padding (in px) between the inner radius of links and the edge of the plot. Increase this when the labels run outside the edges of the plot. Default: 100. |
nodesize |
two element vector of the min and max node size to scale the node circle size. If a size is not provided for each node, then the node size will be the max node size provided in this argument. Default: c(5,20). |
directed |
whether or not the graph is directed. Does not work yet. Need to think about how to implement this cleanly. |
## Not run: require(igraph) ws_graph = watts.strogatz.game(1, 50, 4, 0.05) edgebundle(ws_graph,tension = 0.1,fontsize = 20) ## End(Not run)
## Not run: require(igraph) ws_graph = watts.strogatz.game(1, 50, 4, 0.05) edgebundle(ws_graph,tension = 0.1,fontsize = 20) ## End(Not run)
Widget output function for use in Shiny
edgebundleOutput(outputId, width = "100%", height = "400px")
edgebundleOutput(outputId, width = "100%", height = "400px")
outputId |
Shiny output ID |
width |
width default '100%' |
height |
height default '400px' |
Helper function to convert an igraph to JSON
edgeToJSON_igraph(graph)
edgeToJSON_igraph(graph)
graph |
an igraph |
Helper function to convert edges to JSON
edgeToJSON_matrix(edges)
edgeToJSON_matrix(edges)
edges |
a matrix of edge relationships |
A JSON file enumerating the dependencies between classes in a software class hierarchy. Dependencies are bundled according to the parent packages.
A JSON data file (with txt extension for R)
Sourced from Mike Bostock's examples, see here: http://bl.ocks.org/mbostock/raw/7607999/
## Not run: filepath = system.file("sampleData", "flare-imports.json", package = "edgebundleR") edgebundle(filepath,width=800,height=800,fontsize=8,tension=0.95) ## End(Not run)
## Not run: filepath = system.file("sampleData", "flare-imports.json", package = "edgebundleR") edgebundle(filepath,width=800,height=800,fontsize=8,tension=0.95) ## End(Not run)
Widget render function for use in Shiny
renderEdgebundle(expr, env = parent.frame(), quoted = FALSE)
renderEdgebundle(expr, env = parent.frame(), quoted = FALSE)
expr |
edgebundle expression |
env |
environment |
quoted |
logical, default = FALSE |
Save a edge buyndle graph to an HTML file for sharing with others. The HTML can include it's dependencies in an adjacent directory or can bundle all dependencies into the HTML file (via base64 encoding).
saveEdgebundle(x, file, selfcontained = TRUE)
saveEdgebundle(x, file, selfcontained = TRUE)
x |
plot to save (e.g. result of calling the function
|
file |
File to save HTML into |
selfcontained |
Whether to save the HTML as a single self-contained file (with external resources base64 encoded) or a file with external resources placed in an adjacent directory. |
Opens a shiny GUI to facilitate interaction with the edgebundle function
shinyedge(x)
shinyedge(x)
x |
an appropriately structured JSON file (see vignette for details) or a square symmetric matrix (e.g. correlation matrix) or an igraph object. |