Skip to content

Instantly share code, notes, and snippets.

@cpsievert
Last active June 7, 2023 17:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cpsievert/4eb44f8812bccc741ba01f857eaa62ab to your computer and use it in GitHub Desktop.
Save cpsievert/4eb44f8812bccc741ba01f857eaa62ab to your computer and use it in GitHub Desktop.
library(bslib)
library(bsicons)
library(crosstalk)
library(plotly)
dat <- SharedData$new(dplyr::sample_n(diamonds, 1000))
accordion_filters <- accordion(
accordion_panel(
"Dropdowns", icon = bs_icon("menu-app"),
filter_select("cut", "Cut", dat, ~cut),
filter_select("color", "Color", dat, ~color),
filter_select("clarity", "Clarity", dat, ~clarity)
),
accordion_panel(
"Numerical", icon = bs_icon("sliders"),
filter_slider("depth", "Depth", dat, ~depth, ticks = FALSE),
filter_slider("table", "Table", dat, ~table, ticks = FALSE)
)
)
page_fillable(
card(
card_header("Groups of diamond filters"),
layout_sidebar(
sidebar = sidebar(bg = "white", accordion_filters),
plot_ly(dat) |> add_histogram(x = ~price)
)
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment