Filtering with crosstalk
This is a test of an interactive RMarkdown document
within the govuk-hugo theme, on 2022-04-07 using {crosstalk}
to interactively filter data.
Prepare data
{crosstalk} is an R package that supports interactive
Rmarkdown files, it is particularly useful for govukhugo as
it can support client-side data processing and therefore enables complex
interactivity without relying on Shiny. To use {crosstalk}
we initiate a SharedData object by a call to
crosstalk::SharedData$new().
Compatability issues means this only works with tables (via
govukhgo::govuk_datatable()) and not yet with interactive
plots (via {plotly}), it has not yet been tested with
interactive maps (via {leaflet}).
Filtering the table
Once enabled we can use {crosstalk} to filter the data
object, and to link tables and plots. At present only the
filter_select() and filter_checkbo() filters
are supported for use in govukhugo.
|
|
{crosstalk} is designed to work with the Bootstrap CSS framework which does
not work well with the GOV.UK Design System, therefore the filters
should be wrapped inside a call to govukhugo::unstrap() to
remove the Bootstrap dependencies.
|
|