tidyverse / tidyversedashboard

Tidyverse activity dashboard
https://tidyverse.org/dashboard
Other
72 stars 24 forks source link

Proposed alternative plot for first tab #25

Closed hadley closed 4 years ago

hadley commented 4 years ago
library(forcats)

issue_data3 <- issue_data2 %>% 
  filter(!is.na(event)) %>% 
  select(event, owner, package, num = issue, type, status) %>% 
  mutate(
    date = as.Date(event),
    event = NULL,
    n = if_else(status %in% c("closed", "merged"), -1, 1)
  )

daily <- issue_data3 %>% 
  group_by(date, type, status, ) %>% 
  summarise(n = sum(n))

daily %>% 
  mutate(status = fct_relevel(status, "opened", "merged")) %>% 
  ggplot(aes(date, n, fill = type)) + 
  geom_col() +
  facet_grid(status ~ ., scales = "free_y", space = "free") +
  labs(
    title = "Daily changes in issues and PRs",
    x = NULL,
    y = NULL
  ) + 
  scale_y_continuous(breaks = scales::breaks_width(20), expand = c(0, 5)) +
  scale_fill_brewer(palette = "Set1", guide = NULL) + 
  scale_x_date(date_breaks = "1 week", date_labels = "%b %d", date_minor_breaks = "1 day")

image

jimhester commented 4 years ago

LGTM, want to do a PR to make the change?