library(highcharter)
state_palette <- setNames(c("#F2A05C", "#8C5A48", "#5C0424"), c("California", "Illinois", "Pennsylvania"))
state_election_votes %>%
filter(State %in% c("California", "Illinois", "Pennsylvania")) %>%
mutate(demVote = demVote * 100) %>%
hchart("line", hcaes(x = Year, y = demVote, group = State), color = state_palette, lineWidth = 3) %>%
hc_yAxis(title = list(text = ""), lineWidth = 1, lineColor = 'black', tickWidth = 1, tickColor = 'black',
gridLineWidth = 0, labels = list(format = '{value}%')) %>%
hc_xAxis(title = list(text = ""), lineWidth = 1, lineColor = 'black', tickColor = 'black') %>%
hc_legend(verticalAlign = "top", align = "center", floating = TRUE, y = 70) %>%
hc_title(text = "Percent of Democrat Votes by State", align = 'left') %>%
hc_subtitle(text = "We're a swing state! Go Vote!", align = 'left', style = list(color = 'black')) %>%
hc_add_theme(hc_theme(
chart = list(plotBackgroundColor = 'white'),
title = list(style = list(fontFamily = "Roboto Slab", fontSize = "25px")),
subtitle = list(style = list(fontFamily = "Open Sans", fontSize = "16px", fontStyle = 'italic'))
))