-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added data imports to main.R, and created preliminary skeleton of the…
… topmost module.
- Loading branch information
1 parent
119a13b
commit ef82149
Showing
1 changed file
with
113 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,123 @@ | ||
# ------------------------------------------------------------------------- | ||
# ---------------------------- Libraries/Packages ------------------------- | ||
# ------------------------------------------------------------------------- | ||
|
||
box::use( | ||
shiny[bootstrapPage, div, moduleServer, NS, renderUI, tags, uiOutput], | ||
sf[`st_crs<-`, st_read, st_transform], | ||
shiny[moduleServer, NS, reactive, tagList, tags], | ||
shiny.semantic[semanticPage] | ||
) | ||
|
||
#' @export | ||
# ------------------------------------------------------------------------- | ||
# ---------------------------------- Modules ------------------------------ | ||
# ------------------------------------------------------------------------- | ||
|
||
# box::use( | ||
# app/view[], | ||
# app/logic[] | ||
# ) | ||
|
||
# ------------------------------------------------------------------------- | ||
# ----------------------------- Helper Functions -------------------------- | ||
# ------------------------------------------------------------------------- | ||
|
||
card <- function(class, ...) {tags$div(class = class, ...)} | ||
Check warning on line 24 in app/main.R GitHub Actions / Run linters and tests
|
||
|
||
custom_grid <- function(class, ...) {tags$div(class = class, ...)} | ||
Check warning on line 26 in app/main.R GitHub Actions / Run linters and tests
|
||
|
||
# ------------------------------------------------------------------------- | ||
# ------------------------------ Data Imports ----------------------------- | ||
# ------------------------------------------------------------------------- | ||
|
||
# Ridership Data Sets | ||
route_bar_chart_data <- read.csv(file = "data/ridership_data/route_bar_chart_data.csv") | ||
stop_bar_chart_data <- read.csv(file = "data/ridership_data/stop_bar_chart_data.csv") | ||
|
||
# Mapping Data Sets | ||
bus_routes <- st_read("data/shape_data/mbta_bus_routes/bus_route_and_ridership.shp") | ||
bus_stops <- st_read("data/shape_data/mbta_bus_stops/bus_stop_and_ridership.shp") | ||
|
||
rapid_routes <- st_read("data/shape_data/mbta_rapid_routes/rapid_route_and_ridership.shp") | ||
rapid_stops <- st_read("data/shape_data/mbta_rapid_stops/rapid_stop_and_ridership.shp") | ||
|
||
ferry_routes <- st_read("data/shape_data/mbta_ferry_routes/ferry_route_and_ridership.shp") | ||
ferry_stops <- st_read("data/shape_data/mbta_ferry_stops/ferry_stop_and_ridership.shp") | ||
|
||
# Set the CRS code for each sf object | ||
st_crs(bus_routes) <- 4326 | ||
st_crs(bus_stops) <- 4326 | ||
|
||
st_crs(rapid_routes) <- 4326 | ||
st_crs(rapid_stops) <- 4326 | ||
|
||
st_crs(ferry_routes) <- 4326 | ||
st_crs(ferry_stops) <- 4326 | ||
|
||
bus_routes <- st_transform(bus_routes, crs = 4326) | ||
bus_stops <- st_transform(bus_stops, crs = 4326) | ||
|
||
rapid_routes <- st_transform(rapid_routes, crs = 4326) | ||
rapid_stops <- st_transform(rapid_stops, crs = 4326) | ||
|
||
ferry_routes <- st_transform(ferry_routes, crs = 4326) | ||
ferry_stops <- st_transform(ferry_stops, crs = 4326) | ||
|
||
# ------------------------------------------------------------------------- | ||
# ------------------------------ UI Function ------------------------------ | ||
# ------------------------------------------------------------------------- | ||
|
||
ui <- function(id) { | ||
ns <- NS(id) | ||
bootstrapPage( | ||
uiOutput(ns("message")) | ||
tagList( | ||
semanticPage( | ||
# ------------------------------- | ||
# ----- Layout for App Body ----- | ||
# ------------------------------- | ||
tags$div(class = "body-content-grid", | ||
card(class = "map-card", | ||
tags$div(class = "mbta-map", | ||
"MBTA Map") | ||
), | ||
card(class = "plot-card", | ||
tags$div(class = "mbta-route-bar-chart", | ||
"Route Bar Chart") | ||
), | ||
card(class = "plot-card", | ||
tags$div(class = "mbta-stop-bar-chart", | ||
"Stop Bar Chart") | ||
) | ||
) | ||
) | ||
) | ||
} | ||
|
||
#' @export | ||
# ------------------------------------------------------------------------- | ||
# ----------------------------- Server Function --------------------------- | ||
# ------------------------------------------------------------------------- | ||
|
||
server <- function(id) { | ||
moduleServer(id, function(input, output, session) { | ||
output$message <- renderUI({ | ||
div( | ||
style = "display: flex; justify-content: center; align-items: center; height: 100vh;", | ||
tags$h1( | ||
tags$a("Check out Rhino docs!", href = "https://appsilon.github.io/rhino/") | ||
) | ||
) | ||
}) | ||
}) | ||
moduleServer( | ||
id, | ||
function(input, output, session) { | ||
# ------------------------------ | ||
# ----- Reactive Data Sets ----- | ||
# ------------------------------ | ||
|
||
# Mapping Data Sets | ||
shape_list <- reactive({ | ||
list(bus_routes = bus_routes, bus_stops = bus_stops, | ||
rapid_routes = rapid_routes, rapid_stops = rapid_stops, | ||
ferry_routes = ferry_routes, ferry_stops = ferry_stops) | ||
}) | ||
|
||
# Bar Chart Data Sets | ||
route_data <- reactive({ route_bar_chart_data }) | ||
stop_data <- reactive({ stop_bar_chart_data }) | ||
|
||
# ---------------------------------------------- | ||
# ----- Initialize Module Server Functions ----- | ||
# ---------------------------------------------- | ||
|
||
} | ||
) | ||
} |