-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathDragableFunctions.R
49 lines (41 loc) · 1 KB
/
DragableFunctions.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
library(shiny)
dataSelect <- reactiveValues(type = "all")
# To be called from ui.R
DragableChartOutput <- function(inputId, width = "500px", height = "500px") {
style <- sprintf(
fmt = "width: %s; height: %s;",
validateCssUnit(width),
validateCssUnit(height)
)
tagList(
includeScript(src = "d3.v3.min.js"),
includeScript("ChartRendering.js"),
div(
id = inputId,
class = "Dragable",
style = style,
tag("svg", list())
)
)
}
# To be called from server.R
renderDragableChart <- function(expr, env = parent.frame(), quoted = FALSE, color = "orange", r = 10) {
installExprFunction(
expr = expr,
name = "data",
eval.env = env,
quoted = quoted
)
function(){
data <- lapply(
X = 1:dim(data())[1],
FUN = function(idx){
list(x = data()$x[idx], y = data()$y[idx], r = r)
}
)
list(
data = data,
col = color
)
}
}