Flame Graph
Data
Options ▾
/R/run_app.RMemoryTime
#' Run example app
#'
#' @return A shiny app object
#' @export
#' @import shiny
run_app <- function() {
# serve js tools for Monkey test (in case proxy blocks external scripts)
addResourcePath("gremlins", "inst/shinyValidator-js")
# DON'T CHANGE (INTERNAL TO SHINYVALIDATOR)
if (!exists(".enable_reactlog")) .enable_reactlog <- FALSE
if (!exists(".profile_code")) .profile_code <- FALSE
if (.enable_reactlog || .profile_code) {
tmp <- body(app_server)
start <- length(tmp) + 1 # start just before the closing }
body(app_server)[[start]] <- substitute(
onSessionEnded(function() {
stopApp(reactlog())
})
)
}
runApp(shinyApp(app_ui, app_server), test.mode = TRUE)
}
globalVariables(c("app_ui", "app_server"))
/R/app_ui.RMemoryTime
#' The application User-Interface
#'
#' @param request Internal parameter for `{shiny}`.
#' DO NOT REMOVE.
#' @import shiny
#' @noRd
app_ui <- function(request) {
tagList(
# Leave this function for adding external resources
golem_add_external_resources(),
# Your application UI logic
fluidPage(
selectInput(
"var",
"Select var",
choices = colnames(echarts_df)[-1],
selected = "Population"
),
echarts4rOutput("echarts_plot"),
selectInput(
"col",
"Select a column",
choices = colnames(datasets::mtcars),
selected = "mpg"
),
plotOutput("ggplot_plot")
)
)
}
#' Add external Resources to the Application
#'
#' This function is internally used to add external
#' resources inside the Shiny application.
#'
#' @import shiny
#' @importFrom golem add_resource_path activate_js favicon bundle_resources
#' @noRd
golem_add_external_resources <- function() {
add_resource_path(
"www", app_sys("app/www")
)
tags$head(
favicon(),
bundle_resources(
path = app_sys("app/www"),
app_title = "shinyValidatorTest2"
)
# Add here other external resources
# for example, you can add shinyalert::useShinyalert()
)
}
/R/app_server.RMemoryTime
#' The application server-side
#'
#' @param input,output,session Internal parameters for {shiny}. DO NOT REMOVE.
#' @import shiny
#' @import echarts4r
#' @noRd
app_server <- function(input, output, session) {
# Your application server logic
output$echarts_plot <- renderEcharts4r({
Sys.sleep(3)
make_echart(input$var)
})
output$ggplot_plot <- renderPlot({
make_ggplot(input$col)
})
}
/R/utils.RMemoryTime
# "const customClicker = gremlins.species.clicker({
# // which mouse event types will be triggered
# clickTypes: ['click'],
# // Click only if element has id obs
# canClick: (element) => element.id === 'obs',
# // by default, the clicker gremlin shows its action by a red circle
# // overriding showAction() with an empty function makes the gremlin action invisible
# showAction: (x, y) => {},
# });
#
# gremlins.createHorde({
# randomizer: new gremlins.Chance(1234), // repeatable
# species: [customClicker],
# mogwais: [gremlins.mogwais.alert(),gremlins.mogwais.gizmo()],
# strategies: [
# gremlins.strategies.distribution({
# distribution: [1], // custom
# delay: 10 // default
# })
# ]
# }).unleash().then(() => {
# console.log('Gremlins test success')
# });"
echarts_df <- state.x77 %>%
as.data.frame() %>%
tibble::rownames_to_column("State")
make_echart <- function(var) {
# add the same id as plot output outside shiny
# to avoid random snapshot id issue
id <- if (!shiny::isRunning()) "echarts_plot" else NULL
State <- NULL;
echarts_df %>%
e_charts(x = State, elementId = id) %>% # initialize and set x
e_line_(serie = var) # add a line
}
#' @import ggplot2
make_ggplot <- function(var = "cyl") { # default to mpg
ggplot(datasets::mtcars, aes_(x = as.name(var))) + geom_histogram(binwidth = 5)
}
profvis::pauserun_apprunAppui.Calldivserver$<-cmphcmphcmphcmphhrun_apprunAppoutput$ggplot_plotrenderFunchybrid_chaindotryCatchtryCatchListtryCatchOnedoTryCatchcaptureStackTracesdomain$wrapSyncwithCallingHandlerswithVisibleforcedrawReactive<reactive:plotObj>hybrid_chaindotryCatchtryCatchListtryCatchOnedoTryCatchcaptureStackTracesdomain$wrapSyncwithCallingHandlerswithVisibleforcedo.calldrawPlothybrid_chaindotryCatchtryCatchListtryCatchOnedoTryCatchcaptureStackTracesdomain$wrapSyncwithCallingHandlerswithVisibleforce01002003004005006007008009001,000