Column

Treemap

Column

Pie Chart

Bar Chart

---
title: "Dashboard of Orange County Accidents 2016-2019"
author: "Aaron Long"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
    source_code: embed
---

```{r setup, include=FALSE}
library(flexdashboard)
library(dbplyr)
library(dplyr)
library(leaflet)
library(highcharter)
```

Column {data-width=550}
-----------------------------------------------------------------------

### Treemap

```{r}
orange <- car %>%
          filter(County=='Orange'& State=='FL')

orange_cityS <- orange %>%
                count(City,Severity) 

hchart(orange_cityS, "treemap", hcaes(x = City, value = n, color = Severity))%>%
hc_title(text = "Treemap by City",useHTML = TRUE) %>%
hc_subtitle(text = "(1 is lowest accident severity and 4 is highest severity)",
            align = "center", style = list(color = "#24437b", fontWeight = "bold"))
```

Column {data-width=450}
-----------------------------------------------------------------------

### Pie Chart

```{r}
orange_st <- orange %>%
          count(Street) %>%
          arrange(desc(n))%>%
          top_n(n=15,wt=n)

hchart(orange_st, "pie", hcaes(x=Street, y = n)) %>%
hc_title(text = "Top 15 Roads for Accidents") 
```

### Bar Chart

```{r}
orange$month = format(as.Date(orange$Start_Time), "%m")
orange$year = format(as.Date(orange$Start_Time), "%Y")

orange_m <- orange %>%
  filter(year >= 2018) %>%
  group_by(year)%>%
  count(month) 
  
hchart(orange_m, "column", hcaes(x = month, y = n, group = year)) %>%
hc_title(text = "Accidents by Month for 2018 and 2019")
```