crashes per hour donut plot added
This commit is contained in:
parent
626dc8f24d
commit
caa0588328
@ -76,8 +76,8 @@ ui <- fluidPage(
|
||||
),
|
||||
mainPanel(
|
||||
# wykresiki
|
||||
plotlyOutput("weekdayCrashes")
|
||||
|
||||
plotlyOutput("weekdayCrashes"),
|
||||
plotlyOutput("hourCrashes")
|
||||
)
|
||||
)
|
||||
),
|
||||
@ -131,7 +131,7 @@ server <- function(input, output, session) {
|
||||
|
||||
plot_ly(
|
||||
x = week_day$Weekday, y = week_day$n,
|
||||
name = 'Week Day Crashes', type = "bar"
|
||||
name = 'No. of crashes per week day', type = "bar"
|
||||
) %>%
|
||||
layout(title = 'Week Day Crashes',
|
||||
xaxis = list(title = "Weekdays",
|
||||
@ -141,6 +141,42 @@ server <- function(input, output, session) {
|
||||
|
||||
})
|
||||
|
||||
output$hourCrashes <- renderPlotly({
|
||||
|
||||
crashes_per_hours <- airplane_crashes %>% count(Hour)
|
||||
crashes_per_hours <- crashes_per_hours[-c(1,26,27,28), ]
|
||||
|
||||
|
||||
#dodanie pozycji labeli
|
||||
# crashes_per_hours <- crashes_per_hours %>%
|
||||
# arrange(Hour) %>%
|
||||
# mutate(lab.ypos = cumsum(n) - 0.5*n)
|
||||
#
|
||||
# ggplot(crashes_per_hours, aes(x = "", y = n, fill = Hour)) +
|
||||
# geom_bar(stat="identity", width=1, color="white") +
|
||||
# coord_polar("y", start=0) +
|
||||
# geom_text(aes(y = lab.ypos, label = Hour), color = "white")+
|
||||
# theme_void() +
|
||||
# theme(legend.position="none")
|
||||
|
||||
df <- crashes_per_hours
|
||||
#df <- paste(df$Hour, ":00")
|
||||
df <- df %>% arrange(Hour)
|
||||
fig <- df %>% plot_ly(labels = ~Hour, values = ~n, sort=FALSE)
|
||||
fig <- fig %>% add_pie(hole = 0.4)
|
||||
fig <- fig %>% layout(title = "No. of crashes per hour", xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
|
||||
yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE))
|
||||
|
||||
fig
|
||||
|
||||
|
||||
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
output$operatorCrashes <- renderStreamgraph({
|
||||
|
||||
@ -237,7 +273,7 @@ server <- function(input, output, session) {
|
||||
map_data <- cntry %>%
|
||||
full_join(world_map, by = c('Country' = 'region'))
|
||||
|
||||
map_pal = c("#E0DFD5", "#E4B363", "#E97F02", '#EF6461', '#313638')
|
||||
map_pal = c('#E6CE39', '#F09B3C', '#D94B41', '#CD3CF0', '#555CEB')
|
||||
|
||||
ggplot_obj <-
|
||||
ggplot(map_data, aes(x = long, y = lat, group = group, fill = m)) +
|
||||
|
Loading…
Reference in New Issue
Block a user