Ifeanyi's picture
Update app.R
e8710e5 verified
raw
history blame
2.06 kB
library(shiny)
library(shinyjs)
library(shinythemes)
library(shinycssloaders)
library(GWalkR)
# set global options for spinner
options(spinner.size = 1,
spinner.color.background = "#FFFFFF",
spinner.color = "lightblue")
ui <- fluidPage(
useShinyjs(),
title = "Data Explorer",
theme = shinytheme("cyborg"),
tags$h3(id = "title", tags$strong("Graphic-Walker Data Explorer"),style = "text-align:center;color:lightblue;"),
tags$a(href = "https://github.com/Ifeanyi55", tags$strong("Maintainer"),target = "_blank",style = "text-decoration:none;color:lightblue;margin-left:1250px;margin-bottom:1000px"),
tags$img(src = "plot.jpeg",width = 170,height = 100),br(),br(),
sidebarLayout(
sidebarPanel(width = 3,style = "border-width:5px;border-color:lightblue;border-radius:25px;", fileInput("target_upload",h5(strong("Click to Upload CSV File"),style = "color:lightblue;"),
accept = c("text/csv"),
buttonLabel = strong("Select. . .",style = "color:lightblue;"),
placeholder = "No file selected"),
actionButton("reset","Reset",icon = icon("refresh")),
br(),br(),a(href = "https://github.com/Kanaries/GWalkR",h6(strong("Learn More"),style = "color:lightblue;"),target = "_blank",style = "text-decoration: none;")),
mainPanel(withSpinner(gwalkrOutput(outputId = "explorer",width = "114%"),type = 1)
)
)
)
server <- function(input,output,session){
file_upload <- reactive({
inFile <- input$target_upload
if(is.null(inFile)){return(NULL)}
data <- read.csv(inFile$datapath,header = TRUE,sep = ",")
return(data)
})
output$explorer <- renderGwalkr({
tryCatch(
{
gwalkr(file_upload(),dark = "dark")
},
error = function(e){
message("Could not display interface")
}
)
})
# refresh app
observeEvent(input$reset,{
runjs("location.reload();")
})
}
shinyApp(ui,server)