Skip to content

Instantly share code, notes, and snippets.

@jimbrig
Last active June 7, 2020 18:44
Show Gist options
  • Save jimbrig/f8c7b94b15218f5e88aca5d91683de99 to your computer and use it in GitHub Desktop.
Save jimbrig/f8c7b94b15218f5e88aca5d91683de99 to your computer and use it in GitHub Desktop.
Function for Observing a click and changing a tab in a tabsetpanel
#' Gauge Chart Oberserver Function
#'
#' Apply's on.click functionality to change tab when a gauge chart is clicked
#'
#' @param gauge_id id of gauge chart
#' @param tab_to_select tab to move to
#' @param tab_id equals histogram_tab_box for all cases
#' @param session shiny server session
#'
#' @return invisible - used for side effects
observe_gauge_click <- function(gauge_id,
tab_to_select,
tab_id = "histogram_tab_box",
session = getDefaultReactiveDomain()) {
shinyjs::onclick(
id = gauge_id,
expr = {
updateTabsetPanel(session, inputId = tab_id, selected = tab_to_select);
shinyjs::runjs(
"$('html, body').animate({scrollTop:$(document).height()}, 'slow');"
)
}
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment