Commit d263a7f2 authored by Stephanie Wegscheidl's avatar Stephanie Wegscheidl

Try to make download work

parent 9e6e4dbe
...@@ -13,6 +13,8 @@ library(Cairo) #creating the pdf for download ...@@ -13,6 +13,8 @@ library(Cairo) #creating the pdf for download
library(grDevices) # also necessary for the download library(grDevices) # also necessary for the download
library(anytime) # for correctly parsing unixtimestamps into readable date and time formats library(anytime) # for correctly parsing unixtimestamps into readable date and time formats
library(shinydashboard) # creating the structure / dashboard structure-items library(shinydashboard) # creating the structure / dashboard structure-items
library(gridExtra)
server <- function(input, output, session) { server <- function(input, output, session) {
set.seed(122) set.seed(122)
...@@ -177,6 +179,7 @@ server <- function(input, output, session) { ...@@ -177,6 +179,7 @@ server <- function(input, output, session) {
plotname <<- paste("plot", plotCounter, sep="") plotname <<- paste("plot", plotCounter, sep="")
xplotname<<- paste("x",plotname,sep="") xplotname<<- paste("x",plotname,sep="")
yplotname<<-paste("y",plotname, sep="") yplotname<<-paste("y",plotname, sep="")
array_plots <<- list()
#BARCHART box insert #BARCHART box insert
observeEvent(input$check_hist, { observeEvent(input$check_hist, {
...@@ -186,6 +189,8 @@ server <- function(input, output, session) { ...@@ -186,6 +189,8 @@ server <- function(input, output, session) {
plotCounter<<-plotCounter+1 plotCounter<<-plotCounter+1
xplotname<<- paste("x",plotname,sep="") xplotname<<- paste("x",plotname,sep="")
yplotname<<-paste("y",plotname, sep="") yplotname<<-paste("y",plotname, sep="")
array_plots <<- c(array_plots, plotname)
#Inserting box & Chart #Inserting box & Chart
insertUI( insertUI(
...@@ -197,16 +202,18 @@ server <- function(input, output, session) { ...@@ -197,16 +202,18 @@ server <- function(input, output, session) {
collapsible = TRUE, collapsible = TRUE,
selectInput(xplotname, "x-axis", choices=colnames(coconut.df)), selectInput(xplotname, "x-axis", choices=colnames(coconut.df)),
selectInput(yplotname, "y-axis", choices=colnames(coconut.df)), selectInput(yplotname, "y-axis", choices=colnames(coconut.df)),
plotOutput(plotname, height = 400)) plotOutput(plotname, height = 400))
) )
local({ local({
# data handling # data handling
output[[plotname]] <- renderPlot({ output[[plotname]] <- renderPlot({
#assign(paste("data", plotCounter,sep="_"))
data<- structure(list(V1=as.numeric(coconut.df[[input[[xplotname]]]]), data<- structure(list(V1=as.numeric(coconut.df[[input[[xplotname]]]]),
V2=as.numeric(coconut.df[[input[[yplotname]]]])), V2=as.numeric(coconut.df[[input[[yplotname]]]])),
.Names=c("V1","V2"), row.names=c(NA,10L), class = "data.frame") .Names=c("V1","V2"), row.names=c(NA,10L), class = "data.frame")
# New Bar-Plot # New Bar-Plot
barplot(data$V2,data$V1, array_plots <<-arrangeGrob(array_plots, barplot(data$V2,data$V1,
ylab=input[[yplotname]], ylab=input[[yplotname]],
xlab=input[[xplotname]], xlab=input[[xplotname]],
names.arg = data$V1 names.arg = data$V1
...@@ -214,9 +221,10 @@ server <- function(input, output, session) { ...@@ -214,9 +221,10 @@ server <- function(input, output, session) {
#, #,
#las=2 #las=2
#axis.lty=1 #axis.lty=1
) ))
}) })
}) #Local end }) #Local end
}) })
#BARCHART text #BARCHART text
...@@ -249,7 +257,7 @@ server <- function(input, output, session) { ...@@ -249,7 +257,7 @@ server <- function(input, output, session) {
end = parsedEndtimes end = parsedEndtimes
) )
#New Timeline #New Timeline
timevis(data) array_plots <<-arrangeGrob(array_plots,timevis(data))
}) })
}) })
...@@ -481,17 +489,30 @@ server <- function(input, output, session) { ...@@ -481,17 +489,30 @@ server <- function(input, output, session) {
#TODO: DownloadButton #TODO: DownloadButton
output$down.pdf <- downloadHandler( output$down.pdf <- downloadHandler(
print("DOWNLOAD"),
#print(V1)
filename = "download.pdf", filename = "download.pdf",
content = function(file) { content = function(file) {
CairoPDF(file = file, width=12, height=8) CairoPDF(file = file, width=12, height=8)
#boxplot(data$V1, type="box", xlab=input$box_x) #boxplot(data$V1, type="box", xlab=input$box_x)
#m #m
#leafletOutput("map", height = 250) #leafletOutput("map", height = 250)
output$box # output[[plotname]] <- renderPlot({
data<- structure(list(V1=as.numeric(coconut.df[[input$scat_x]]), #
V2=as.numeric(coconut.df[[input$scat_y]])), # #handling data
.Names=c("V1","V2"), row.names=c(NA,6L), class = "data.frame") # data<- structure(list(V1=as.numeric(coconut.df[[input[[xplotname]]]])),
plot(data$V1,data$V2, type="p", xlab=input$scat_x, ylab=input$scat_y ) # .Names=c("V1"), row.names=c(NA,10L), class = "data.frame")
# print(data)
# #new Boxplot
# boxplot(data$V1, type="box", xlab=input[[xplotname]])
#
# })
data<- structure(list(V1=as.numeric(coconut.df[[input[[xplotname]]]])),
.Names=c("V1"), row.names=c(NA,10L), class = "data.frame")
boxplot(data$V1, type="box", xlab=input[[xplotname]])
#print(array_plots)
dev.off() dev.off()
}) }
)
} }
...@@ -139,9 +139,9 @@ ui <- dashboardPage( ...@@ -139,9 +139,9 @@ ui <- dashboardPage(
uiOutput("scat_box"), uiOutput("scat_box"),
uiOutput("box_box"), uiOutput("box_box"),
uiOutput("map_box"), uiOutput("map_box"),
uiOutput("pdfview")#, uiOutput("pdfview"),
# downloadButton("down.pdf","Download") downloadButton("down.pdf","Download")
) )
) )
......
...@@ -8,3 +8,5 @@ install.packages("timevis") ...@@ -8,3 +8,5 @@ install.packages("timevis")
install.packages("Cairo") install.packages("Cairo")
install.packages("grDevices") install.packages("grDevices")
install.packages("gridExtra")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment