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