m <- highlight_key(results_factor2)
widgets <- bscols(
filter_checkbox("school", "School", m, ~school,
inline = TRUE)
)
p <- ggplot(m,
mapping = aes(x = year, y = length(last_name), fill = abs_levels)) +
geom_col() +
facet_wrap(~abs_levels, labeller = as_labeller(chrn_labels)) +
scale_fill_viridis_d() +
scale_x_discrete(labels = NULL) +
scale_y_continuous(labels = NULL) +
labs(x = NULL, y = NULL,
title = "2019-2020 Overall Levels of Chronic Absenteeism") +
theme_minimal() +
theme(legend.position="none")
gg <- highlight(ggplotly(p,
tooltip = "fill"), "plotly_selected")
crosstalk::bscols(
widths = c(2,4,6), widgets, gg, DT::datatable(m,
colnames = c(
'Last Name', 'First Name', 'Year', 'School', 'Level'),
extensions = 'Buttons',
options = list(
dom = 'Bfrtip',
buttons = c('copy', 'csv', 'pdf',
'print')
)))
## Setting the `off` event (i.e., 'plotly_deselect') to match the `on` event (i.e., 'plotly_selected'). You can change this default via the `highlight()` function.