Create a highlight specification to pass on to a chart function

highlight_spec(what, highlight_color = NULL, other_color = NULL)

Arguments

what

character The value(s) to highlight

highlight_color

character The highlight color(s)

other_color

character The color for the non-highlighted values

Value

An object of class ggcharts_highlight_spec

Details

highlight_color must be of length 1 or the same length as what. If it is of length 1 then all values in what are highlighted with the same color.

If highlight_color is NULL (the default) then it is set to the default color of the currently active ggcharts theme, i.e. ggcharts_get_default_color(ggcharts_get_theme()).

If other_color is NULL is is automatically determined from the background color of the currently active ggcharts theme.

Examples

data("biomedicalrevenue") revenue2018 <- biomedicalrevenue[biomedicalrevenue$year == 2018, ] spec <- highlight_spec("Bayer") bar_chart(revenue2018, company, revenue, highlight = spec)
spec <- highlight_spec("Bayer", "black", "gray") bar_chart(revenue2018, company, revenue, highlight = spec)
spec <- highlight_spec(c("Bayer", "Novartis")) bar_chart(revenue2018, company, revenue, highlight = spec)
spec <- highlight_spec(c("Bayer", "AstraZeneca"), c("darkgreen", "darkorange")) bar_chart(revenue2018, company, revenue, highlight = spec)
ggcharts_set_theme("theme_ng") spec <- highlight_spec("Novartis") lollipop_chart(revenue2018, company, revenue, highlight = spec)