The tooltip only shows one value everywhere in the line.
# Function for the tooltip
all_values <- function(x) {
if(is.null(x)) return(NULL)
paste0(names(x), ": ", format(x), collapse = "
")
}
by_age <- gss_cat %>%
filter(!is.na(age)) %>%
group_by(age, marital) %>%
count() %>%
mutate(prop = n / sum(n))
ggvis(by_age, ~age, ~prop, stroke = ~marital) %>%
layer_lines() %>%
add_tooltip(all_values, "hover")