Last active
June 7, 2020 18:44
-
-
Save jimbrig/f8c7b94b15218f5e88aca5d91683de99 to your computer and use it in GitHub Desktop.
Function for Observing a click and changing a tab in a tabsetpanel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' 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