Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a test app for https://github.com/rstudio/shiny/pull/2668 #169

Merged
merged 2 commits into from
Jul 27, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 46 additions & 3 deletions apps/161-discrete-limits/app.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
### Keep this line to manually test this shiny application. Do not edit this line; shinycoreci::::is_manual_app


library(shiny)
library(ggplot2)
library(dplyr)
Expand All @@ -20,7 +19,9 @@ ui <- basicPage(
uiOutput("res1"),
br(),
plotOutput("plot2", brush = "brush2"),
uiOutput("res2")
uiOutput("res2"),
plotOutput("plot3", brush = "brush3"),
uiOutput("res3")
)

server <- function(input, output) {
Expand Down Expand Up @@ -94,6 +95,48 @@ server <- function(input, output) {
}
})

dat <- data.frame(
x = c("a", "b", NA, NA),
y = c(1, 2, 3, 2),
key = c("a", "b", "c", "d"),
stringsAsFactors = FALSE
)

output$plot3 <- renderPlot({
ggplot(dat) +
geom_point(aes(x, y)) +
facet_wrap(~x, scales = "free") +
geom_rect(
data = data.frame(
x1 = 0.8,
x2 = 1.2,
y1 = 2.9,
y2 = 3.1,
x = NA
),
aes(xmin=x1, xmax=x2, ymin=y1, ymax=y2),
alpha = 0, color = "black", lty = 2
) +
ylim(1, 4)
})

brush3key <- reactive({
if (is.null(input$brush3)) return(NULL)
brushedPoints(dat, input$brush3)$key
})

output$res3 <- renderPrint({
if (is.null(brush3key())) {
return(tags$b("Brush the points outlined above"))
}
actual <- brush3key()
if (identical(actual, "c")) {
tags$b("Test passed!", style = "color: green")
} else {
tags$b("Test failed", style = "color: red")
}
})

}

shinyApp(ui, server)
shinyApp(ui, server)
schloerke marked this conversation as resolved.
Show resolved Hide resolved