Skip to content

Commit

Permalink
final version
Browse files Browse the repository at this point in the history
  • Loading branch information
yiqiang committed May 6, 2018
1 parent 001c62f commit 9ccc42f
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 16 deletions.
7 changes: 7 additions & 0 deletions data/aircraft_data.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"Aircraft Series","Africa","Euro","Mediterranean","Pacific"
"A20",0,1715,6386,3477
"B17",2,27858,2520,881
"B24",3,14362,4390,14919
"B25",0,448,7697,8899
"B26",0,8707,2670,212
"GB17",0,8843,50,0
1 change: 1 addition & 0 deletions data/aircraft_text.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<br>The B-24 was used extensively in World War II. It served in every branch of the American armed forces, as well as several Allied air forces and navies, and saw use in every theater of operations. Along with the B-17, the B-24 was the mainstay of the U.S. strategic bombing campaign in the Western European theater.
9 changes: 8 additions & 1 deletion data_preprocessing.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ write.csv(map_data, file = "data/simplified_data.csv", row.names = FALSE)
save(flight_route, file="data/flight_route.rda")

## Part 2: parse data to get obs count ts data
Mission <- df %>% select(`Mission Date`, `Mission ID`, `Theater of Operations`) %>%
Mission <- df %>% select(`Mission Date`, `Mission ID`, `Theater of Operations`, `Aircraft Series`) %>%
filter(is.na(`Mission Date`) == F, is.na(`Theater of Operations`) != TRUE, `Theater of Operations` != 'MADAGASCAR')
Mission$`Mission Date` <- as.Date(anytime::anydate(Mission$`Mission Date`))
Mission$start_month <- cut(Mission$`Mission Date`, "month")
Expand Down Expand Up @@ -80,3 +80,10 @@ save(groupColors, file="data/groupColors.rda")
attack_data <- df %>% filter(is.na(Country) != T, is.na(`Target Country`) != T, is.na(`Target City`) != T) %>%
select(Country, `Target Country`, `Target City`)
write.csv(attack_data, file = "data/attack_data.csv", row.names = FALSE)

## Part 5: Aircraft Series Count
as_ct <- Mission %>% filter(., is.na(`Aircraft Series`) != T, `Aircraft Series` %in% c('B24', 'B17', 'B25', 'B26', 'A20', 'GB17')) %>%
group_by(`Aircraft Series`, `Theater of Operations`) %>%
count() %>% reshape2::dcast(., `Aircraft Series` ~ `Theater of Operations`, value.var = "n")
as_ct[is.na(as_ct)] <- 0
write.csv(as_ct, file = "data/aircraft_data.csv", row.names = FALSE)
22 changes: 20 additions & 2 deletions server.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ load("data/groupColors.rda")
load("data/ajmatrix.rda")
allies_axis_text <- read_file("data/axis_allies.txt")
intro_text <- read_file("data/intro.txt")
as_ct <- read_csv("data/aircraft_data.csv")
aircraft_text <- read_file("data/aircraft_text.txt")
####Sever####
shinyServer(function(input, output, session) {
target_map <- SharedData$new(df_target, key = ~id, group = "grp1")
Expand Down Expand Up @@ -159,7 +161,6 @@ shinyServer(function(input, output, session) {
layout(annotations = annot1) %>% layout(annotations = annot2) %>% layout(annotations = annot3) %>%
layout(annotations = annot4) %>% layout(annotations = annot5) %>% layout(annotations = annot6) %>%
layout(annotations = annot7) %>% layout(annotations = annot8)

p3$elementId <- NULL
p3
})
Expand Down Expand Up @@ -207,7 +208,24 @@ shinyServer(function(input, output, session) {
})

output$allies_axis <- renderText(allies_axis_text)
output$intro <- renderText((intro_text))
output$intro <- renderText(intro_text)
output$fig2_text <- renderText(paste("From top to bottom: B-25, B-17, B-24"))
output$fig1_text <- renderText(paste("USS Arizona (BB-39) sunk and burning furiously"))
output$fig3_text <- renderText(paste("The Big Three - The Allied Leaders at the Yalta Conference"))
output$instruction <- renderText(paste("Use the selection tool on the map to highlight the target area and update plots"))
output$aircraft_text <- renderText(aircraft_text)
output$aircraft_series <- renderPlotly({p4 <- plot_ly(as_ct, x = ~Euro, y = ~`Aircraft Series`, type = "bar", orientation = "h", name = "Euro",
marker = list(color = '#bebada', line = list(color = '#bebada', width = 3))) %>%
add_trace(x = ~Mediterranean, name = 'Mediterranean',
marker = list(color = '#fb8072', line = list(color = '#fb8072', width = 3))) %>%
add_trace(x = ~Pacific, name = 'Pacific',
marker = list(color = '#80b1d3', line = list(color = '#80b1d3', width = 3))) %>%
add_trace(x = ~Africa, name = 'Africa',
marker = list(color = '#8dd3c7', line = list(color = '#8dd3c7', width = 3))) %>%
layout(barmode = "stack",
xaxis = list(title = ""),
yaxis = list(title = ""))
p3$elementId <- NULL
p3})
})

59 changes: 46 additions & 13 deletions ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,17 @@ library(shinydashboard)
library(chorddiag)

shinyUI(dashboardPage(
dashboardHeader(title = "World War II"),
dashboardHeader(title = "World War II",
dropdownMenu(
type = "notifications",
icon = icon("question-circle-o"),
badgeStatus = NULL,
headerText = "Contact",
notificationItem("Yiqiang Zhao", icon = icon("linkedin-square"),
href = "https://www.linkedin.com/in/yqzhao52/"),
notificationItem("Jay Xu", icon = icon("linkedin-square"),
href = "https://www.linkedin.com/in/zhengjie-xu-b75311a7/")
)),
dashboardSidebar(
sidebarMenu(
menuItem(
Expand Down Expand Up @@ -65,7 +75,9 @@ shinyUI(dashboardPage(
column(width = 9,
htmlOutput("allies_axis")),
column(width = 3, align = "center",
img(src = "allied powers.jpg", height = '170px', width = '220px'))))),
fluidRow(img(src = "allied powers.jpg", height = '170px', width = '250px')),
fluidRow(tags$style("#fig3_text {font-size:12px; font-style:italic;}"),
htmlOutput("fig3_text"), align = "center"))))),
fluidRow(
box(splitLayout(
cellWidths = c("12%", "38%", "50%"),
Expand All @@ -78,16 +90,37 @@ shinyUI(dashboardPage(
fluidRow(
box(title = tags$b("Count of Bombing Mission in WW2"), solidHeader = TRUE,
plotlyOutput("timeseries"), width = 12)),
fluidRow(box(title = tags$b("WW2 Introduction"), status = "primary",
solidHeader = F, collapsible = F, width = 12,
fluidRow(
tags$style("#allies_axis {font-size:15px;
fluidRow(
# box(title = tags$b("WW2 Introduction"), status = "primary",
# solidHeader = F, collapsible = F, width = 12,
# fluidRow(
# tags$style("#allies_axis {font-size:15px;
# display:block; }"),
# column(width = 9, htmlOutput("intro")),
# column(width = 3, align = "center",
# img(src = "uss_arizona_burning_sinking-P.jpeg", height = '170px', width = '240px'))))
tabBox(width=12,
tabPanel(tags$b("WW2 Introduction"),
fluidRow(
tags$style("#allies_axis {font-size:15px;
display:block; }"),
column(width = 9, htmlOutput("intro")),
column(width = 3,
fluidRow(align = "center",
img(src = "uss_arizona_burning_sinking-P.jpeg", height = '170px', width = '240px')),
fluidRow(tags$style("#fig1_text {font-size:12px; font-style:italic;}"),
htmlOutput("fig1_text"), align = "center")))),
tabPanel(tags$b("Aircraft Series in WW2"), fluidRow(
tags$style("#allies_axis {font-size:15px;
display:block; }"),
column(width = 9, htmlOutput("intro")),
column(width = 3, align = "center",
img(src = "uss_arizona_burning_sinking-P.jpeg", height = '170px', width = '240px')))
)
))
column(width = 9, plotlyOutput("aircraft_series")),
column(width = 3,
fluidRow(div(img(src = "b24b25b17.jpg", height = '190px', width = '270px')), style="text-align: center;"),
fluidRow(tags$style("#fig2_text {font-size:12px; font-style:italic;}"),
htmlOutput("fig2_text"), align = "center"),
fluidRow(tags$style("#fig2_text {font-size:14px;}"),htmlOutput("aircraft_text")))))
)
)
))
)
)
)))

File renamed without changes
Binary file added www/b24b25b17.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9ccc42f

Please sign in to comment.