Skip to content
Snippets Groups Projects
Verified Commit f5a18103 authored by Ruben van Dijk's avatar Ruben van Dijk
Browse files

appendPlotly function.

parent f33670cd
Branches
No related tags found
No related merge requests found
......@@ -11,14 +11,6 @@ library(lubridate)
library(data.table)
dir.create("libdir")
foldername <- list.files("/tmp", pattern="Rtmp.*", full.names=TRUE)
plotToString <- function(plot) {
randomString <- paste0(sample(c(LETTERS, letters), 5, TRUE), collapse = '')
filename <- paste0(randomString, ".html")
saveWidget(ggplotly(plot), file = filename, selfcontained = FALSE, libdir = "libdir")
response <- read_file(filename)
file.remove(filename)
return(response)
}
doId <- function(input) {
id <- input$id
......@@ -26,7 +18,10 @@ doId <- function(input) {
if(is.null(dates_to_drop)) dates_to_drop <- ""
response <- list()
appendGraph <- function(item) {
appendPlot <- function(item) {
response <<- c(response, list(ggplotly(item)))
}
appendPlotly <- function(item) {
response <<- c(response, list(item))
}
dates_to_drop=as.list(strsplit(dates_to_drop, ","))[[1]]
......@@ -91,21 +86,21 @@ doId <- function(input) {
geom_point(data = tabel_Prs, color="green", alpha=0.7, size=2, show.legend=FALSE)+
labs(title="Datum van alle gezwommen slagen per afstand")+guides(color='none')+
facet_grid(vars(distance), scales='free_y')
appendGraph(tijdlijn_alles)
appendPlot(tijdlijn_alles)
kleurentabel_prs <- ggplot(tabel_Prs, aes(distance, stroke)) +
geom_tile(aes(fill = points)) +
geom_text(aes(label = points)) +
labs(title = "Heatmap punten per slag en afstand") +
theme_bw()
appendGraph(kleurentabel_prs)
appendPlot(kleurentabel_prs)
kleurentabel_Lasts<-ggplot(tabel_LastEntrys, aes(distance, stroke))+
geom_tile(aes(fill = date)) +
geom_text(aes(label = date)) +
labs(title = "Laatst gezwommen per slag en afstand") +
theme_bw()
appendGraph(kleurentabel_Lasts)
appendPlot(kleurentabel_Lasts)
tabel_Prs <- bovennul %>%
group_by(distance, stroke, poolType) %>%
......@@ -116,7 +111,7 @@ doId <- function(input) {
geom_col(position = position_dodge2(preserve = "single")) +
scale_fill_manual(values=kleurenset_afstanden, limits=force)+
labs(title = "Prs: Punten per afstand per slag. Zowel lange - als kortebaan.")
appendGraph(norm_barplot)
appendPlot(norm_barplot)
tabel_LastEntrys<-zonder_split%>%
group_by(distance, stroke, poolType) %>%
......@@ -127,7 +122,7 @@ doId <- function(input) {
geom_col(position = position_dodge2(preserve = "single")) +
labs(title = "Laatste tijden: Punten >0 per afstand per slag", fill = "afstand")+
scale_fill_manual(values=kleurenset_afstanden, drop=TRUE, limits=force)
appendGraph(norm_barplot_last)
appendPlot(norm_barplot_last)
bovennul_sorted=bovennul[order(bovennul$distance, decreasing=TRUE),]
afstandEnslag=interaction(bovennul$distance, bovennul$stroke, sep='m ', drop=TRUE)
......@@ -137,16 +132,16 @@ doId <- function(input) {
geom_point() +
scale_color_manual(values=kleurenset_strokes)+
labs(title = "Punten >0 per datum per afstand")
appendGraph(stippenplot_alles)
appendPlot(stippenplot_alles)
lijnenplot_ineen <- ggplot(bovennul, aes(x = date, y = points, color = afstandEnslag)) +
labs(title = "Punten per afstand, slag en datum") +
geom_line()
appendGraph(lijnenplot_ineen)
appendPlot(lijnenplot_ineen)
lijnenplot_ineen2 <- lijnenplot_ineen+
geom_point(data=bovennul_50m, shape=17, color='black', alpha=0.5)
appendGraph(lijnenplot_ineen2)
appendPlot(lijnenplot_ineen2)
tabel=zonder_split%>% count(distance, stroke)
tabel=tabel[tabel$n>1,]
......@@ -163,7 +158,7 @@ doId <- function(input) {
scale_y_continuous(breaks=seq(0,15*60,30), minor_breaks=seq(0,15*60,10))+
scale_colour_manual(values=kleurenset_strokes)+
facet_wrap(vars(distance), scales = 'free_y')
appendGraph(lijnenplot_gesplitst)
appendPlot(lijnenplot_gesplitst)
return(response)
}
......@@ -178,9 +173,6 @@ app$add_get(
}
dir.create(foldername[[1]])
response <- doId(.req$parameters_query)
response <- map(response, function(input) {
return(ggplotly(input))
})
htmltools::save_html(response, file="test.html", libdir = "libdir")
response <- read_file("test.html")
style <- "<style>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment