server.R 3.02 KB
Newer Older
Stephanie's avatar
Stephanie committed
1 2 3 4 5 6 7 8 9 10
#
# This is the server logic of a Shiny web application. You can run the 
# application by clicking 'Run App' above.
#
# Find out more about building applications with Shiny here:
# 
#    http://shiny.rstudio.com/
#

library(shiny)
11
library(jsonlite)
12
library(DT)
Stephanie's avatar
Stephanie committed
13

Stephanie's avatar
Stephanie committed
14 15
server <- function(input, output) {
  set.seed(122)
16
  
17
  #CoConUT Data import and showing into data site 
18
  output$file1 <- renderDataTable({
19 20 21
    inFile <- input$file1
    if (is.null(inFile))
      return(NULL)
22
    
23 24 25 26 27
    #loading CoConUT data
    json_data_coco <<- fromJSON(paste(inFile$datapath, sep = ""), flatten = TRUE)
    coconut.df <<- json_data_coco[["data"]]
    print(inFile$datapath)
    # setting the table style
28 29 30 31 32 33 34 35 36 37 38 39 40
    datatable(
              cbind(coconut.df), 
              options = list(
                searching = TRUE,
                autoWidth = TRUE,
                rownames = FALSE,
                scroller = TRUE,
                scrollX = TRUE,
                scrollY = "500px",
                fixedHeader = TRUE,
                class = 'cell-border stripe'
              )
    )
41 42 43 44 45
  })
  # Getting 
  output$dataSelector_x <- renderUI({
    selectInput("in1", "x-axis:", as.list(coconut.df),multiple=TRUE, selectize=TRUE) 
  })
46
  
47 48
  output$dataSelector_y <- renderUI({
    selectInput("in1", "y-axis:", as.list(coconut.df),multiple=TRUE, selectize=TRUE) 
49 50
  })
  
51
  
52
  
53
  #TODO: CoCoQuest Output --> Ansätze data[] raus nehmen oder flatten richtig funken
54 55
  output$file2 <- renderDataTable({
    inFile <- input$file2
56 57
    if (is.null(inFile))
      return(NULL)
58
  
59
    
60
    simplifyVector <- c("studyID", "studyName", "description", "tasks$endTime" , "id", "startTime", "endTime")
61
    json_data_quest <- fromJSON(paste(inFile$datapath, sep = ""), simplifyVector = TRUE, simplifyDataFrame = simplifyVector,
62 63 64
                                simplifyMatrix = simplifyVector, flatten = TRUE) 
    print("with simplify: ")
    print(json_data_quest)
65
    
66 67 68 69 70 71 72 73 74 75 76 77 78 79
    ## ANSATZ zum rauslesen der Times: --> not working now
    
    #questLength <<- length(json_data_quest)
    #print("length")
    #print(questLength)
    #data <- c(json_data_quest$tasks[[1]]$`data`[[1]]$endtime, json_data_quest$tasks[[1]]$`data`[[2]]$endtime, json_data_quest$tasks[[1]]$startTime, json_data_quest$tasks[[1]]$endTime, json_data_quest$tasks[[2]]$`data`[[1]]$endtime, json_data_quest$tasks[[2]]$`data`[[2]]$endtime, json_data_endtime$tasks[[2]]$`data`[[3]]$endtime)
    #data<-c(json_data_quest$tasks[[1]]$startTime, json_data_quest$tasks[[1]]$endTime, json_data_quest$tasks[[2]]$startTime, json_data_quest$tasks[[2]]$endTime )
   
    #x<<-0
    #for(x in x:questLength)
    #{data<<-c(json_data_quest$tasks[[x]]$startTime, json_data_quest$tasks[[x]]$endTime)
    #x=x+1}
    #print("data: ")
    #print(data)
80 81
    
  })
82

83
  
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
  #histdata <- rnorm(500)
  
  #output$plot1 <- renderPlot({
  #data <- histdata[seq_len(input$slider)]
  #hist(data)
  #})
  
  ##MAP 
  
  #m <- leaflet()
  #m <- addTiles(m)
  #x=1
  #for(x in 1:2019){
  #m <- addMarkers(m,lng=longitude[x], lat=latitude[x]) #addPolylines does not work
  #x=x+1}
  #m
  #}
Stephanie's avatar
Stephanie committed
101
}