Commit b22b6574 authored by Stephanie Wegscheidl's avatar Stephanie Wegscheidl

Map using data works

parent 551647c4
......@@ -15,14 +15,14 @@ library(plotly)
server <- function(input, output, session) {
set.seed(122)
#Continue to data page
#Continue to data page
observeEvent(input$dataSite, {
updateTabItems(session, "tabs",selected = "data")
})
#DATA PAGE
#DATA PAGE
......@@ -35,12 +35,12 @@ server <- function(input, output, session) {
#loading CoConUT data
json_data_coco <- fromJSON(paste(inFile$datapath, sep = ""), flatten = TRUE)
coconut.df <<- json_data_coco[["data"]]
lastCoConUT <<- inFile$name
#print("coconut:")
#coconut.df$timestamp <- format(coconut.df$timestamp, format="%d-%B-%Y %H:%M:%S")
#print(coconut.df)
if(is.null(coconut.df$timestamp)){}
......@@ -93,22 +93,22 @@ server <- function(input, output, session) {
if(is.null(coconut.df$interaction.touch)){}
else{touch<<-coconut.df$interaction.touch}
# setting the table style
datatable(
cbind(coconut.df),
options = list(
searching = TRUE,
autoWidth = TRUE,
rownames = FALSE,
scroller = TRUE,
scrollX = TRUE,
scrollY = "500px",
fixedHeader = TRUE,
class = 'cell-border stripe'
)
cbind(coconut.df),
options = list(
searching = TRUE,
autoWidth = TRUE,
rownames = FALSE,
scroller = TRUE,
scrollX = TRUE,
scrollY = "500px",
fixedHeader = TRUE,
class = 'cell-border stripe'
)
)
})
#last coconut_name
......@@ -131,10 +131,10 @@ server <- function(input, output, session) {
totalST <<- c(anytime(as.numeric(json_data_quest$startTime)/1000))
print(json_data_quest)
#unix parsed
dat <- do.call(rbind, json_data_quest$tasks$data)
endtimes <<- c(dat$endtime)
parsedEndtimes <<- anytime(endtimes/1000)
......@@ -148,7 +148,7 @@ server <- function(input, output, session) {
print("together")
print(together)
all <- rbind(together)
#setting the table style
datatable(
cbind(tasks, endtimes),
......@@ -156,7 +156,7 @@ server <- function(input, output, session) {
searching = FALSE,
rownames = TRUE,
class = 'cell-border stripe'
)
)
)
})
......@@ -166,7 +166,7 @@ server <- function(input, output, session) {
return(NULL)
else lastCoCoQuest
})
#cocoQuest Starttime
output$totalStarttime <- renderText({
if (is.null(input$quest))
......@@ -184,15 +184,15 @@ server <- function(input, output, session) {
})
#View PAGE
#View PAGE
#Title Input
output$title <- renderText({ input$title })
#barchart
output$input_hist_x <- renderUI({
if (is.null(input$nut))
return(NULL)
return(NULL)
selectInput("in1", "x-axis:", cbind("unixTime", "longitude", "latitude", "speed", "gps.acc","lux", "light.acc","acc.coordinates", "acc.acc","bluetooth","ble.bpm","ble.bpmlist","ble.hrv","ble.hrvlist","activity.name", "acctivity.confidence","screen.status" ,"touch"),multiple=TRUE, selectize=TRUE)
})
......@@ -204,14 +204,14 @@ server <- function(input, output, session) {
#Timeline
output$input_time_x <- renderUI({
if (is.null(input$nut))
return(NULL)
if (is.null(input$nut))
return(NULL)
selectInput("in3", "x-axis:", cbind("unixTime", "longitude", "latitude", "speed", "gps.acc","lux", "light.acc","acc.coordinates", "acc.acc","bluetooth","ble.bpm","ble.bpmlist","ble.hrv","ble.hrvlist","activity.name", "acctivity.confidence","screen.status" ,"touch"),multiple=TRUE, selectize=TRUE)
})
output$input_time_y <- renderUI({
output$input_time_y <- renderUI({
if (is.null(input$nut))
return(NULL)
selectInput("in4", "y-axis:", cbind("unixTime", "longitude", "latitude", "speed", "gps.acc","lux", "light.acc","acc.coordinates", "acc.acc","bluetooth","ble.bpm","ble.bpmlist","ble.hrv","ble.hrvlist","activity.name", "acctivity.confidence","screen.status" ,"touch"),multiple=TRUE, selectize=TRUE)
......@@ -220,14 +220,14 @@ server <- function(input, output, session) {
#Map
output$input_map <- renderUI({
if (is.null(input$nut))
return(NULL)
selectInput("in5", "Data:", cbind("unixTime", "speed", "gps.acc","lux", "light.acc","acc.coordinates", "acc.acc","bluetooth","ble.bpm","ble.bpmlist","ble.hrv","ble.hrvlist","activity.name", "acctivity.confidence","screen.status" ,"touch"),multiple=TRUE, selectize=TRUE)
})
if (is.null(input$nut))
return(NULL)
selectInput("in5", "Data:", cbind("unixTime", "speed", "gps.acc","lux", "light.acc","acc.coordinates", "acc.acc","bluetooth","ble.bpm","ble.bpmlist","ble.hrv","ble.hrvlist","activity.name", "acctivity.confidence","screen.status" ,"touch"),multiple=TRUE, selectize=TRUE)
})
output$input_map_x <- renderUI({
if (is.null(input$nut))
return(NULL)
return(NULL)
selectInput("in5", "x-axis:", cbind("unixTime", "longitude", "latitude", "speed", "gps.acc","lux", "light.acc","acc.coordinates", "acc.acc","bluetooth","ble.bpm","ble.bpmlist","ble.hrv","ble.hrvlist","activity.name", "acctivity.confidence","screen.status" ,"touch"),multiple=TRUE, selectize=TRUE)
})
......@@ -239,7 +239,7 @@ server <- function(input, output, session) {
#linechart
output$input_line_x <- renderUI({
if (is.null(input$nut))
return(NULL)
......@@ -247,7 +247,7 @@ server <- function(input, output, session) {
})
output$input_line_y <- renderUI({
if (is.null(input$nut))
if (is.null(input$nut))
return(NULL)
selectInput("in8", "y-axis:", cbind("unixTime", "longitude", "latitude", "speed", "gps.acc","lux", "light.acc","acc.coordinates", "acc.acc","bluetooth","ble.bpm","ble.bpmlist","ble.hrv","ble.hrvlist","activity.name", "acctivity.confidence","screen.status" ,"touch"),multiple=TRUE, selectize=TRUE)
})
......@@ -255,75 +255,75 @@ server <- function(input, output, session) {
#Continue to dashboard page
observeEvent(input$dashboardSite, {
updateTabItems(session, "tabs",selected = "dashboard")
})
plotCounter <<- 0
#ADD BARCHART BUTTON
observeEvent(input$check_hist, {
plotCounter<<-plotCounter+1
print(plotCounter)
plotname <- paste("plot", plotCounter, sep="")
print(plotname)
xplotname<- paste("x",plotname,sep="")
yplotname<-paste("y",plotname, sep="")
insertUI(
selector= "#viewpanel", #wo will ichs hinhaben
ui= box( title="Barchart",
status= "warning",
solidHeader = TRUE,
collapsible = TRUE,
selectInput(xplotname, "x-axis", choices=colnames(coconut.df)),
selectInput(yplotname, "y-axis", choices=colnames(coconut.df)),
plotOutput(plotname, height = 250))
)
})
#DASHBOARD
#BAR VIEW
observeEvent(input$check_hist, {
plotCounter<<-plotCounter+1
print(plotCounter)
plotname <- paste("plot", plotCounter, sep="")
print(plotname)
xplotname<- paste("x",plotname,sep="")
yplotname<-paste("y",plotname, sep="")
insertUI(
selector= "#viewpanel", #wo will ichs hinhaben
ui= box( title="Barchart",
status= "warning",
solidHeader = TRUE,
collapsible = TRUE,
selectInput(xplotname, "x-axis", choices=colnames(coconut.df)),
selectInput(yplotname, "y-axis", choices=colnames(coconut.df)),
plotOutput(plotname, height = 250))
)
})
#DASHBOARD
#BAR VIEW
local({
output[[plotname]] <- renderPlot({
print(plotname)
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,6L), class = "data.frame")
#Neues Plot
barplot(data$V1,data$V2,
ylab= input$yplotname,
xlab=input$xplotname)
})
output[[plotname]] <- renderPlot({
print(plotname)
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,6L), class = "data.frame")
#Neues Plot
barplot(data$V1,data$V2,
ylab= input$yplotname,
xlab=input$xplotname)
})
})
## ALTES PLOT
#a=1
#for(a in 1:length(coconut.df$bluetooth.numOfBTDevices)){
#g <-geom_bar(mapping = NULL, data = , stat = "count",
# position = "stack", width = NULL, binwidth = NULL, na.rm = FALSE,
# show.legend = NA, inherit.aes = TRUE)
#g <- ggplot(coconut.df, aes("timestamp","bluetooth"))
#g + geom_bar()
# a=a+1}
#g
#hist(bluetooth)
## ALTES PLOT
#a=1
#for(a in 1:length(coconut.df$bluetooth.numOfBTDevices)){
#g <-geom_bar(mapping = NULL, data = , stat = "count",
# position = "stack", width = NULL, binwidth = NULL, na.rm = FALSE,
# show.legend = NA, inherit.aes = TRUE)
#g <- ggplot(coconut.df, aes("timestamp","bluetooth"))
#g + geom_bar()
# a=a+1}
#g
#hist(bluetooth)
#TIMELINE
......@@ -334,13 +334,13 @@ server <- function(input, output, session) {
solidHeader = TRUE,
collapsible = TRUE,
timevisOutput("time", height = 250)
)
)
})
#TODO: Timelineview
output$time <- renderTimevis({
print("TIME wird aufgerufen")
print("Length:")
print(length(parsedEndtimes))
print("combined")
......@@ -356,14 +356,14 @@ server <- function(input, output, session) {
end = parsedEndtimes
)
timevis(data)
})
output$texttimeline <- renderText({
"Check Timeline for getting a Timeline about CoCoQuest Tasks and Questions."
})
#linechart
output$line_box <- renderUI({
......@@ -385,7 +385,7 @@ server <- function(input, output, session) {
V2=as.numeric(coconut.df[[input$line_y]])),
.Names=c("V1","V2"), row.names=c(NA,6L), class = "data.frame")
plot(data$V1,data$V2, type="l", ylab=input$line_y, xlab=input$line_x)
})
# Scatterplot
......@@ -443,24 +443,37 @@ server <- function(input, output, session) {
# MAP VIEW
output$map <- renderLeaflet({
print("MAP wird aufgerufen")
data <- as.numeric(coconut.df[[input$map_data]])
max_data<- max(data)
print("MAX DATA")
print(max_data)
c<-1
for(c in 1:length(data)){
data[c]<-(data[c]/max_data)*5
}
print(data)
m <<- leaflet()
print("MAP wird aufgerufen")
data <- as.numeric(coconut.df[[input$map_data]])
max_data<<- max(data)
c<-1
for(c in 1:length(data)){
data[c]<-(data[c]/max_data)*10
}
colorData <-
cut(
data,
c(0, 2, 5, 7, 10),
include.lowest = T,
lables = c('<2', '<5', '<7', '<10')
)
print("colorData")
print(colorData)
colorGrad <- colorFactor('RdYlGn', colorData)
print("colorGrad")
print(colorGrad(colorData))
m <- leaflet()
x=1
m <- addTiles(m)
for(x in 1:length(coconut.df$gps.latitude)){
m <- addCircleMarkers(m,lng=as.numeric(coconut.df$gps.longitude[x]), lat=as.numeric(coconut.df$gps.latitude[x]), radius = data[x], color ="red") #addPolylines does not work
x=x+1}
m<-addCircleMarkers(m,lng=as.numeric(coconut.df$gps.longitude), lat=as.numeric(coconut.df$gps.latitude), radius = data, color = colorGrad(colorData)) #addPolylines does not work
m<-addLegend(m, 'bottomright', pal=colorGrad, values=colorData, title=' ',opacity=1)
m
})
......@@ -508,21 +521,21 @@ server <- function(input, output, session) {
})
# url <- paste0(cdat$url_protocol,"//",cdat$url_hostname,":", cdat$url_port, cdat$url_pathname,cdat$url_search)
#output$downButton <- downloadHandler(
# filename="dashboard.png",
#content=function(file){
# observeEvent(input$downButton, {
#appshot("cocoVisR/dashboard", file = "dashboard.png", port = getOption("shiny.port"), envvars = NULL)
#})
#}
# filename="dashboard.png",
#content=function(file){
# observeEvent(input$downButton, {
#appshot("cocoVisR/dashboard", file = "dashboard.png", port = getOption("shiny.port"), envvars = NULL)
#})
#}
#)
#SOME STUFF
#SOME STUFF
#histdata <- rnorm(500)
......
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