-
Notifications
You must be signed in to change notification settings - Fork 1
/
dragables.R
54 lines (47 loc) · 1.07 KB
/
dragables.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
53
54
dataSelect <- reactiveValues(type = "all")
DragableChartOutput <- function(inputId, width = "100%", height = "100%") {
style <- sprintf(
fmt = "width: %s; height: %s;",
validateCssUnit(width),
validateCssUnit(height)
)
tagList(
includeScript("www/d3.min.js"),
includeScript("www/ChartRendering.js"),
div(
id = inputId,
class = "Dragable",
style = style
)
)
}
# To be called from server.R
renderDragableChart <- function(expr, env = parent.frame(),
quoted = FALSE, labels = LETTERS,
width = NULL, sameval = FALSE) {
installExprFunction(
expr = expr,
name = "data",
eval.env = env,
quoted = quoted
)
installExprFunction(
expr = sameval,
name = "sameval",
eval.env = env,
quoted = quoted
)
function() {
data <- lapply(
X = seq(length(data())),
FUN = function(idx){
list(x = labels[idx], y = data()[idx])
}
)
list(
data = data,
width = width,
sameval = sameval()
)
}
}