Skip to content

Commit 3b1875a

Browse files
rpkyleohaanika
andauthored
Add dashCytoscape v0.3.0 for R (#138)
* chore: use build:backends * chore: update R package to v0.3.0 * chore: update CHANGELOG.md * Create demos for R (#68) Co-authored-by: Aanika Rahman <[email protected]>
1 parent 1812577 commit 3b1875a

20 files changed

+2924
-3610
lines changed

.Rbuildignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ lib/
77
.builderrc
88
.eslintrc
99
.npmignore
10+
.editorconfig
11+
.eslintignore
12+
.prettierrc
13+
.circleci
14+
.github
1015

1116
# demo folder has special meaning in R
1217
# this should hopefully make it still
@@ -15,7 +20,7 @@ demo/.*\.js
1520
demo/.*\.html
1621
demo/.*\.css
1722

18-
# ignore python files/folders
23+
# ignore Python files/folders
1924
setup.py
2025
usage.py
2126
setup.py

DESCRIPTION

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
Package: dashCytoscape
2-
Title: A Component Library for Dash aimed at facilitating network visualization in R, wrapped around Cytoscape.js
3-
Version: 0.1.1
4-
Description: A Component Library for Dash aimed at facilitating network visualization in R, wrapped around Cytoscape.js
2+
Title: A Component Library for 'Dash' aimed at facilitating network visualization in R, wrapped around Cytoscape.js.
3+
Version: 0.3.0
4+
Description: A Component Library for 'Dash' aimed at facilitating network visualization in R, wrapped around Cytoscape.js.
55
Depends: R (>= 3.0.2)
66
Imports:
77
Suggests:
8+
Authors@R: c(person("Chris", "Parmer", email = "[email protected]", role = c("aut")), person("Xing Han", "Lu", email = "[email protected]", role = c("cre")), person(family = "Plotly Technologies, Inc.", role = "cph"))
89
License: MIT + file LICENSE
10+
Copyright: Plotly Technologies, Inc.
911
URL: https://github.com/plotly/dash-cytoscape
1012
BugReports: https://github.com/plotly/dash-cytoscape/issues
1113
Encoding: UTF-8
1214
LazyData: true
1315
KeepSource: true
14-
Author: The Plotly Team [aut]
15-
Maintainer: The Plotly Team <[email protected]>

R/cytoCytoscape.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# AUTO GENERATED FILE - DO NOT EDIT
22

3-
cytoCytoscape <- function(id=NULL, className=NULL, style=NULL, elements=NULL, stylesheet=NULL, layout=NULL, pan=NULL, zoom=NULL, panningEnabled=NULL, userPanningEnabled=NULL, minZoom=NULL, maxZoom=NULL, zoomingEnabled=NULL, userZoomingEnabled=NULL, boxSelectionEnabled=NULL, autoungrabify=NULL, autolock=NULL, autounselectify=NULL, autoRefreshLayout=NULL, tapNode=NULL, tapNodeData=NULL, tapEdge=NULL, tapEdgeData=NULL, mouseoverNodeData=NULL, mouseoverEdgeData=NULL, selectedNodeData=NULL, selectedEdgeData=NULL) {
3+
cytoCytoscape <- function(id=NULL, autoRefreshLayout=NULL, autolock=NULL, autoungrabify=NULL, autounselectify=NULL, boxSelectionEnabled=NULL, className=NULL, elements=NULL, generateImage=NULL, imageData=NULL, layout=NULL, maxZoom=NULL, minZoom=NULL, mouseoverEdgeData=NULL, mouseoverNodeData=NULL, pan=NULL, panningEnabled=NULL, responsive=NULL, selectedEdgeData=NULL, selectedNodeData=NULL, style=NULL, stylesheet=NULL, tapEdge=NULL, tapEdgeData=NULL, tapNode=NULL, tapNodeData=NULL, userPanningEnabled=NULL, userZoomingEnabled=NULL, zoom=NULL, zoomingEnabled=NULL) {
44

5-
props <- list(id=id, className=className, style=style, elements=elements, stylesheet=stylesheet, layout=layout, pan=pan, zoom=zoom, panningEnabled=panningEnabled, userPanningEnabled=userPanningEnabled, minZoom=minZoom, maxZoom=maxZoom, zoomingEnabled=zoomingEnabled, userZoomingEnabled=userZoomingEnabled, boxSelectionEnabled=boxSelectionEnabled, autoungrabify=autoungrabify, autolock=autolock, autounselectify=autounselectify, autoRefreshLayout=autoRefreshLayout, tapNode=tapNode, tapNodeData=tapNodeData, tapEdge=tapEdge, tapEdgeData=tapEdgeData, mouseoverNodeData=mouseoverNodeData, mouseoverEdgeData=mouseoverEdgeData, selectedNodeData=selectedNodeData, selectedEdgeData=selectedEdgeData)
5+
props <- list(id=id, autoRefreshLayout=autoRefreshLayout, autolock=autolock, autoungrabify=autoungrabify, autounselectify=autounselectify, boxSelectionEnabled=boxSelectionEnabled, className=className, elements=elements, generateImage=generateImage, imageData=imageData, layout=layout, maxZoom=maxZoom, minZoom=minZoom, mouseoverEdgeData=mouseoverEdgeData, mouseoverNodeData=mouseoverNodeData, pan=pan, panningEnabled=panningEnabled, responsive=responsive, selectedEdgeData=selectedEdgeData, selectedNodeData=selectedNodeData, style=style, stylesheet=stylesheet, tapEdge=tapEdge, tapEdgeData=tapEdgeData, tapNode=tapNode, tapNodeData=tapNodeData, userPanningEnabled=userPanningEnabled, userZoomingEnabled=userZoomingEnabled, zoom=zoom, zoomingEnabled=zoomingEnabled)
66
if (length(props) > 0) {
77
props <- props[!vapply(props, is.null, logical(1))]
88
}
99
component <- list(
1010
props = props,
1111
type = 'Cytoscape',
1212
namespace = 'dash_cytoscape',
13-
propNames = c('id', 'className', 'style', 'elements', 'stylesheet', 'layout', 'pan', 'zoom', 'panningEnabled', 'userPanningEnabled', 'minZoom', 'maxZoom', 'zoomingEnabled', 'userZoomingEnabled', 'boxSelectionEnabled', 'autoungrabify', 'autolock', 'autounselectify', 'autoRefreshLayout', 'tapNode', 'tapNodeData', 'tapEdge', 'tapEdgeData', 'mouseoverNodeData', 'mouseoverEdgeData', 'selectedNodeData', 'selectedEdgeData'),
13+
propNames = c('id', 'autoRefreshLayout', 'autolock', 'autoungrabify', 'autounselectify', 'boxSelectionEnabled', 'className', 'elements', 'generateImage', 'imageData', 'layout', 'maxZoom', 'minZoom', 'mouseoverEdgeData', 'mouseoverNodeData', 'pan', 'panningEnabled', 'responsive', 'selectedEdgeData', 'selectedNodeData', 'style', 'stylesheet', 'tapEdge', 'tapEdgeData', 'tapNode', 'tapNodeData', 'userPanningEnabled', 'userZoomingEnabled', 'zoom', 'zoomingEnabled'),
1414
package = 'dashCytoscape'
1515
)
1616

R/internal.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.dashCytoscape_js_metadata <- function() {
22
deps_metadata <- list(`dash_cytoscape` = structure(list(name = "dash_cytoscape",
3-
version = "0.1.1", src = list(href = NULL,
3+
version = "0.3.0", src = list(href = NULL,
44
file = "deps"), meta = NULL,
55
script = 'dash_cytoscape.min.js',
66
stylesheet = NULL, head = NULL, attachment = NULL, package = "dashCytoscape",

dash-info.yaml

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,62 @@
11
pkg_help_description: >-
2-
A Component Library for Dash aimed at facilitating network visualization in R, wrapped around Cytoscape.js
2+
A Component Library for 'Dash' aimed at facilitating network visualization in R, wrapped around Cytoscape.js.
33
pkg_help_title: >-
4-
A Component Library for Dash aimed at facilitating network visualization in R, wrapped around Cytoscape.js
4+
A Component Library for 'Dash' aimed at facilitating network visualization in R, wrapped around Cytoscape.js.
5+
pkg_authors: >-
6+
c(person("Chris", "Parmer", email = "[email protected]", role = c("aut")), person("Xing Han", "Lu", email = "[email protected]", role = c("cre")), person(family = "Plotly Technologies, Inc.", role = "cph"))
7+
pkg_copyright: >-
8+
Plotly Technologies, Inc.
9+
r_examples:
10+
- name: cytoCytoscape
11+
dontrun: FALSE
12+
code: |
13+
if (interactive()) {
14+
library(dash)
15+
library(dashCytoscape)
16+
17+
app <- Dash$new()
18+
19+
app$layout(
20+
cytoCytoscape(
21+
id='cytoscape-elements-boolean',
22+
layout = list(name = 'preset'),
23+
style = list(width = '100\%', height = '400px'),
24+
elements=list(
25+
list(
26+
data = list(id = 'one', label = 'Locked'),
27+
position = list(x = 75, y = 75),
28+
locked = TRUE
29+
),
30+
list(
31+
data = list(id = 'two', label = 'Selected'),
32+
position = list(x = 75, y = 200),
33+
selected = TRUE
34+
),
35+
list(
36+
data = list(id = 'three', label = 'Not Selectable'),
37+
position = list(x = 200, y = 75),
38+
selectable = FALSE
39+
),
40+
list(
41+
data = list(id = 'four', label = 'Not Grabbable'),
42+
position = list(x = 200, y = 200),
43+
grabbable = FALSE
44+
),
45+
list(
46+
data = list(source = 'one', target = 'two')
47+
),
48+
list(
49+
data = list(source = 'two', target = 'three')
50+
),
51+
list(
52+
data = list(source = 'three', target = 'four')
53+
),
54+
list(
55+
data = list(source = 'two', target = 'four')
56+
)
57+
)
58+
)
59+
)
60+
61+
app$run_server()
62+
}

demosR/usage-animated-bfs.R

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# original demo: http://js.cytoscape.org/demos/animated-bfs/
2+
# code: https://github.com/cytoscape/cytoscape.js/tree/master/documentation/demos/animated-bfs
3+
#
4+
# note: animation not implemented yet, please refer to code.
5+
6+
library(dash)
7+
library(dashCytoscape)
8+
library(jsonlite)
9+
10+
app <- Dash$new()
11+
12+
# define data
13+
elements <- list(
14+
list('data' = list('id' = 'a')),
15+
list('data' = list('id' = 'b')),
16+
list('data' = list('id' = 'c')),
17+
list('data' = list('id' = 'd')),
18+
list('data' = list('id' = 'e')),
19+
list('data' = list('id' = 'a"e', 'weight' = 1, 'source' = 'a', 'target' = 'e')),
20+
list('data' = list('id' = 'ab', 'weight' = 3, 'source' = 'a', 'target' = 'b')),
21+
list('data' = list('id' = 'be', 'weight' = 4, 'source' = 'b', 'target' = 'e')),
22+
list('data' = list('id' = 'bc', 'weight' = 5, 'source' = 'b', 'target' = 'c')),
23+
list('data' = list('id' = 'ce', 'weight' = 6, 'source' = 'c', 'target' = 'e')),
24+
list('data' = list('id' = 'cd', 'weight' = 2, 'source' = 'c', 'target' = 'd')),
25+
list('data' = list('id' = 'de', 'weight' = 7, 'source' = 'd', 'target' = 'e'))
26+
)
27+
28+
# define app layout
29+
app$layout(
30+
htmlDiv(
31+
list(
32+
cytoCytoscape(
33+
id = 'cytoscape',
34+
elements = elements,
35+
layout = list(
36+
'name' = 'breadthfirst',
37+
'directed' = TRUE,
38+
'roots' = '#a',
39+
'padding' = 10
40+
),
41+
stylesheet = list(
42+
list(
43+
'selector' = 'node',
44+
'style' = list(
45+
'content' = 'data(id)'
46+
)
47+
), list(
48+
'selector' = 'edge',
49+
'style' = list(
50+
'curve-style' = 'bezier',
51+
'target-arrow-shape' = 'triangle',
52+
'width' = 4,
53+
'line-color' = '#ddd',
54+
'target-arrow-color' = '#ddd'
55+
)
56+
)
57+
),
58+
style = list(
59+
'width' = '100%',
60+
'height' = '100%',
61+
'position' = 'absolute',
62+
'left' = 0,
63+
'top' = 0,
64+
'z-index' = 999
65+
)
66+
)
67+
)
68+
)
69+
)
70+
71+
app$run_server(debug = TRUE)

demosR/usage-breadthfirst-layout.R

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# original demo: http://js.cytoscape.org/demos/images-breadthfirst-layout/
2+
#
3+
# note: click animation is not implemented
4+
5+
library(dash)
6+
library(dashCytoscape)
7+
library(jsonlite)
8+
9+
app <- Dash$new()
10+
11+
# define data
12+
elements <- list(
13+
list('data' = list('id' = 'cat')),
14+
list('data' = list('id' = 'bird')),
15+
list('data' = list('id' = 'ladybug')),
16+
list('data' = list('id' = 'aphid')),
17+
list('data' = list('id' = 'rose')),
18+
list('data' = list('id' = 'grasshopper')),
19+
list('data' = list('id' = 'plant')),
20+
list('data' = list('id' = 'wheat')),
21+
list('data' = list('source' = 'cat', 'target' = 'bird')),
22+
list('data' = list('source' = 'bird', 'target' = 'ladybug')),
23+
list('data' = list('source' = 'bird', 'target' = 'grasshopper')),
24+
list('data' = list('source' = 'grasshopper', 'target' = 'plant')),
25+
list('data' = list('source' = 'grasshopper', 'target' = 'wheat')),
26+
list('data' = list('source' = 'ladybug', 'target' = 'aphid')),
27+
list('data' = list('source' = 'aphid', 'target' = 'rose'))
28+
)
29+
30+
# define stylesheet
31+
stylesheet <- list(
32+
list(
33+
'selector' = 'node',
34+
'style' = list(
35+
'height' = 80,
36+
'width' = 80,
37+
'background-fit' = 'cover',
38+
'border-color' = '#000',
39+
'border-width' = 3,
40+
'border-opacity' = 0.5
41+
)
42+
),
43+
list(
44+
'selector' = 'edge',
45+
'style' = list(
46+
'curve-style' = 'bezier',
47+
'width' = 6,
48+
'target-arrow-shape' = 'triangle',
49+
'line-color' = '#ffaaaa',
50+
'target-arrow-color' = '#ffaaaa'
51+
)
52+
),
53+
list(
54+
'selector' = '#bird',
55+
'style' = list(
56+
'background-image' = 'https://farm8.staticflickr.com/7272/7633179468_3e19e45a0c_b.jpg'
57+
)
58+
),
59+
list(
60+
'selector' = '#cat',
61+
'style' = list(
62+
'background-image' = 'https://farm2.staticflickr.com/1261/1413379559_412a540d29_b.jpg'
63+
)
64+
),
65+
list(
66+
'selector' = '#ladybug',
67+
'style' = list(
68+
'background-image' = 'https://farm4.staticflickr.com/3063/2751740612_af11fb090b_b.jpg'
69+
)
70+
),
71+
list(
72+
'selector' = '#aphid',
73+
'style' = list(
74+
'background-image' = 'https://farm9.staticflickr.com/8316/8003798443_32d01257c8_b.jpg'
75+
)
76+
),
77+
list(
78+
'selector' = '#rose',
79+
'style' = list(
80+
'background-image' = 'https://farm6.staticflickr.com/5109/5817854163_eaccd688f5_b.jpg'
81+
)
82+
),
83+
list(
84+
'selector' = '#grasshopper',
85+
'style' = list(
86+
'background-image' = 'https://farm7.staticflickr.com/6098/6224655456_f4c3c98589_b.jpg'
87+
)
88+
),
89+
list(
90+
'selector' = '#plant',
91+
'style' = list(
92+
'background-image' = 'https://farm1.staticflickr.com/231/524893064_f49a4d1d10_z.jpg'
93+
)
94+
),
95+
list(
96+
'selector' = '#wheat',
97+
'style' = list(
98+
'background-image' = 'https://farm3.staticflickr.com/2660/3715569167_7e978e8319_b.jpg'
99+
)
100+
)
101+
)
102+
103+
# define app layout
104+
app$layout(
105+
htmlDiv(
106+
list(
107+
cytoCytoscape(
108+
id = 'cytoscape',
109+
elements = elements,
110+
stylesheet = stylesheet,
111+
layout = list(
112+
'name' = 'breadthfirst',
113+
'directed' = TRUE,
114+
'padding' = 10
115+
),
116+
style = list(
117+
'width' = '100%',
118+
'height' = '100%',
119+
'position' = 'absolute',
120+
'left' = 0,
121+
'top' = 0
122+
)
123+
)
124+
)
125+
)
126+
)
127+
128+
app$run_server(debug = TRUE)

demosR/usage-circle-layout.R

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# original demo: http://js.cytoscape.org/demos/circle-layout/
2+
3+
library(dash)
4+
library(dashCytoscape)
5+
library(jsonlite)
6+
7+
app <- Dash$new()
8+
9+
# load data
10+
elements <- fromJSON("demos/data/circle-layout/data.json")
11+
12+
# define app layout
13+
app$layout(
14+
htmlDiv(
15+
list(
16+
cytoCytoscape(
17+
id = 'cytoscape',
18+
elements = elements,
19+
layout = list('name' = 'circle'),
20+
stylesheet = list(
21+
list(
22+
'selector' = 'node',
23+
'style' = list(
24+
'height' = 20,
25+
'width' = 20,
26+
'background-color' = '#e8e406'
27+
)
28+
),
29+
list(
30+
'selector' = 'edge',
31+
'style' = list(
32+
'curve-style' = 'haystack',
33+
'haystack-radius' = 0,
34+
'width' = 5,
35+
'opacity' = 0.5,
36+
'line-color' = '#f2f08c'
37+
)
38+
)
39+
),
40+
style = list(
41+
'width' = '100%',
42+
'height' = '100%',
43+
'position' = 'absolute',
44+
'left' = 0,
45+
'top' = 0,
46+
'z-index' = 999
47+
)
48+
)
49+
)
50+
)
51+
)
52+
53+
app$run_server(debug = TRUE)

0 commit comments

Comments
 (0)