-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshinyCyJS.R
52 lines (44 loc) · 1.35 KB
/
shinyCyJS.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
library(shiny)
library(openxlsx)
library(shinyCyJS)
ui = function(){
fluidPage(
ShinyCyJSOutput(outputId = 'cy',width = "100%",height = "900px"),
)
}
server = function(input, output, session){
node_data<-reactive({read.xlsx("node.xlsx")})
edge_data<-reactive({read.xlsx("edge.xlsx")})
node = reactive({
data.frame(
id = node_data()[,"name"],
width = as.numeric(node_data()[,"size"]),
height = node_data()[,"size"],
shape = "ellipse",
bgColor = node_data()[,"color"],
bgFill = "solid",
label = node_data()[,"name"],
borderColor = "#FFFFFF",
borderWidth=1,
labelColor="#00000",
fontSize = 10
)
})
edge = reactive({
data.frame(
source = edge_data()[,1],
target = edge_data()[,2],
####### error #######
# width = 3,
# width = as.numeric(edge_data()[,"edge_width"]),
#####################
lineStyle = edge_data()[,"type"],
lineColor = edge_data()[,"edge_color"]
)
})
nodes = reactive({buildElems(node(), type = 'Node')})
edges = reactive({buildElems(edge(), type = 'Edge')})
obj = reactive({shinyCyJS(c(nodes(), edges()),layout = list(name = "cola"),width ="100%",height="900px")})
output$cy = renderShinyCyJS({obj()})
}
shinyApp(ui,server, options = list(launch.browser = TRUE, display.mode ='normal'))