-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathserver.R
More file actions
71 lines (62 loc) · 2.15 KB
/
server.R
File metadata and controls
71 lines (62 loc) · 2.15 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
##################################
# Created by EPI-interactive
# 27 Feb 2020
# https://www.epi-interactive.com
##################################
function(input, output) {
plot_function <- function(n, mean) {
y <- list(visible=T,
showgrid=T,
showline=T,
zeroline=F,
zerolinecolor="#fff",
title = paste0("<b>Norm(", n, ")</b>"))
x <- list(visible=T,
showgrid=F,
showline=T,
zeroline=F,
zerolinecolor="#fff",
categoryarray = c("<b>Trace 1</b>", "<b>Trace 2</b>"),
categoryorder = "array")
hoverlabel <- list(
bgcolor = "white",
bordercolor = "black",
align = "left",
font=list(
size = 14,
color = "black")
)
plot_ly(type = "box") %>%
add_trace(y = ~rnorm(n),
name = "<b>Trace 1</b>",
fillcolor = '#CEF0F4',
marker = list(color = '#01515E'),
line = list(color = '#01515E')
) %>%
add_trace(y = ~rnorm(n, mean),
name = "<b>Trace 2</b>",
marker = list(color = '#D66100'),
fillcolor = '#FBF2DC',
line = list(color = '#D66100')
) %>%
layout(xaxis = x,
yaxis = y,
showlegend = FALSE,
hoverlabel = hoverlabel)
}
plot_example_1_chart <- reactive({plot_function(input$plot_example_1_n, input$plot_example_1_mean)})
output$plot_example_1 <- renderPlotly({plot_example_1_chart()})
output$downloadReport <- downloadHandler(
filename = "report.pdf",
content = function(file) {
src <- normalizePath('report.Rnw')
# temporarily switch to the temp dir, in case you do not have write
# permission to the current working directory
owd <- setwd(tempdir())
on.exit(setwd(owd))
file.copy(src, 'report.Rnw', overwrite = TRUE)
out = knit2pdf('report.Rnw', clean = TRUE)
file.rename(out, file)
}
)
}