---
output: js4shiny::html_document_plain
---

```{r frappeChart, message=FALSE}
library(dplyr)
library(tidyr)
library(babynames)

data <-
  babynames %>% 
  filter(
    name %in% c("Ruth", "August"),
    year >= 1980
  ) %>% 
  group_by(year, name) %>% 
  summarize(n = sum(n)) %>% 
  ungroup() %>% 
  pivot_wider(year, name, values_from = n)

frappeCharts::frappeChart(
  data,
  title = "This. Is. Awwesome.", 
  elementId = "name-chart",
  lineOptions = list(regionFill = TRUE),
  axisOptions = list(xIsSeries = TRUE),
  colors = c("#466683", "#44bc96"),
  width = "100%",
  tooltipOptions = list(
    formatTooltipX = htmlwidgets::JS("d => 'Year: ' + d"),
    formatTooltipY = htmlwidgets::JS("d => d + ' babies'")
  )
)
```
