gantt chart + highcharter


theme

library(highcharter)
library(tidyverse)
library(glue)
library(lubridate)

colz <- c("#d18975", "#8fd175", "#3f2d54", "#75b8d1", "#fd5c63", "#c9d175", "#d1ab75", "#d175b8", "#758bd1")


theme_ipsum <- function(...) {
  theme <- highcharter::hc_theme(
    colors = c(
      "#3f2d54",
      "#758bd1",
      "#2d543d",
      "#8fd175"
    ), chart = list(style = list(
      fontFamily = "Roboto",
      color = "#666666"
    )), title = list(align = "left", style = list(
      fontFamily = "Roboto",
      fontWeight = "bold", fontSize = "19px"
    )), subtitle = list(
      align = "left",
      style = list(fontFamily = "Roboto", fontSize = "15px")
    ),
    legend = list(align = "right", verticalAlign = "bottom"),
    xAxis = list(
      gridLineWidth = 1, gridLineColor = "#FFFFFF",
      lineColor = "#FFFFFF", minorGridLineColor = "#FFFFFF",
      tickColor = "#FFFFFF", tickWidth = 0, title = list(align = "high")
    ),
    yAxis = list(
      gridLineColor = "#FFFFFF", lineColor = "#FFFFFF",
      minorGridLineColor = "#FFFFFF", tickColor = "#FFFFFF",
      tickWidth = 0, title = list(align = "high")
    ), plotOptions = list(
      line = list(marker = list(enabled = FALSE)),
      spline = list(marker = list(enabled = FALSE)), area = list(marker = list(enabled = FALSE)),
      areaspline = list(marker = list(enabled = FALSE)),
      arearange = list(marker = list(enabled = FALSE)),
      bubble = list(maxSize = "10%")
    )
  )
  theme <- structure(theme, class = "hc_theme")
  if (length(list(...)) > 0) {
    theme <- highcharter::hc_theme_merge(theme, highcharter::hc_theme(...))
  }
  theme
}

get data

max_ds <- "2020-12-31"

dates_seq <- seq.Date(ymd(20130901), ymd(max_ds), by = "days")


seq_date_chr <- function(x, y) {
  seq.Date(ymd(x), ymd(y), by = "days") %>% as.character()
}

titles <- tibble(
  company = c("Arbor Advisors", "Public Defender", "Red Tower Farms", "Quantcast", "Quantcast", "Airbnb", "Slack"),
  title = c("Research Analyst", "Court Document Transcriber", "Advisor", "Product Insights Analyst", "Product Insights Manager", "Data Scientist", "Data Scientist"),
  dates = list(
    seq_date_chr("2013-09-12", "2014-06-05"),
    seq_date_chr("2013-10-13", "2015-06-05"),
    seq_date_chr("2015-06-13", "2015-09-05"),
    seq_date_chr("2016-01-01", "2018-02-28"),
    seq_date_chr("2018-03-01", "2018-08-01"),
    seq_date_chr("2018-09-01", "2020-07-05"),
    seq_date_chr("2020-08-31", max_ds)
  )
) %>%
  mutate(
    rn = row_number(),
    key = glue("{company}-{title}") %>% as.character()
  )



color_n <- titles$rn %>% max()


pal <- RColorBrewer::brewer.pal(color_n, "Paired")

data <- unique(titles$key) %>%
  map_df(., function(x) {
    tmp <- filter(titles, key == x)
    target_dates <- unlist(tmp$dates) %>% ymd()

    tibble(
      date = dates_seq
    ) %>%
      mutate(company = tmp$company, title = tmp$title, key = tmp$key) %>%
      filter(date %in% target_dates)
  })





df <- inner_join(data, titles) %>%
  group_by(key) %>%
  filter(date == min(date) | date == max(date)) %>%
  ungroup() %>%
  mutate(tooltip_dt = format(date, "%Y - %B")) %>%
  arrange(date, rn) %>%
  filter(!is.na(company)) %>% 
  select(date, company, title, key, rn, tooltip_dt)


df %>% 
  knitr::kable()
date company title key rn tooltip_dt
2013-09-12 Arbor Advisors Research Analyst Arbor Advisors-Research Analyst 1 2013 - September
2013-10-13 Public Defender Court Document Transcriber Public Defender-Court Document Transcriber 2 2013 - October
2014-06-05 Arbor Advisors Research Analyst Arbor Advisors-Research Analyst 1 2014 - June
2015-06-05 Public Defender Court Document Transcriber Public Defender-Court Document Transcriber 2 2015 - June
2015-06-13 Red Tower Farms Advisor Red Tower Farms-Advisor 3 2015 - June
2015-09-05 Red Tower Farms Advisor Red Tower Farms-Advisor 3 2015 - September
2016-01-01 Quantcast Product Insights Analyst Quantcast-Product Insights Analyst 4 2016 - January
2018-02-28 Quantcast Product Insights Analyst Quantcast-Product Insights Analyst 4 2018 - February
2018-03-01 Quantcast Product Insights Manager Quantcast-Product Insights Manager 5 2018 - March
2018-08-01 Quantcast Product Insights Manager Quantcast-Product Insights Manager 5 2018 - August
2018-09-01 Airbnb Data Scientist Airbnb-Data Scientist 6 2018 - September
2020-07-05 Airbnb Data Scientist Airbnb-Data Scientist 6 2020 - July
2020-08-31 Slack Data Scientist Slack-Data Scientist 7 2020 - August
2020-12-31 Slack Data Scientist Slack-Data Scientist 7 2020 - December

make plot

highchart() %>%
  hc_add_series(df, "line", hcaes(x = date, y = rn, group = key), lineWidth = 12) %>%
  hc_xAxis(
    type = "datetime", # labels = list(format='{%Y}'),
    plotLines = list(
      list(
        label = list(text = "<b> Graduated: </b> UC Davis <i>(B.A.) </i> <br>  <b>Major: </b><i> Economics</i> <br>  <b>Minor: </b> <i>Middle East South Asia</i>", rotation = 0),
        color = "grey",
        width = 1,
        zIndex = 5,
        dashStyle = "dot",
        value = datetime_to_timestamp(as.Date("2013-09-01"))
      )
    )
  ) %>%
  hc_legend(enabled = FALSE) %>%
  hc_yAxis(labels = list(format = "{}")) %>%
  hc_tooltip(formatter = JS("function(){
                            return '<b>' + this.point.title + '<br>' +
                            '<i>' + this.point.tooltip_dt + '<br>' +
                            'at ' + this.point.company
                            }")) %>%
  hc_title(text = "WHAT I\'VE BEEN UP TO", align = "center") %>%
  hc_add_theme(theme_ipsum()) %>%
  hc_colors(colors = pal) %>%
  hc_size(height = 250)