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

Fix invisible grob plot on popup #175

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 2 additions & 7 deletions R/plot_with_settings.R
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,6 @@ plot_with_settings_srv <- function(id,
if (plot_type() == "gg" && dblclicking) {
plot_r() +
ggplot2::coord_cartesian(xlim = ranges$x, ylim = ranges$y, expand = FALSE)
} else if (plot_type() == "grob") {
# calling grid.draw on plot_r() is needed;
# otherwise the plot will not re-render if the user triggers the zoom in or out feature of the browser.
grid::grid.newpage()
grid::grid.draw(plot_r())
} else {
plot_r()
}
Expand All @@ -377,14 +372,14 @@ plot_with_settings_srv <- function(id,
p_height <- reactive(`if`(!is.null(input$height), input$height, height[1]))
p_width <- reactive(`if`(!is.null(input$width), input$width, default_slider_width()[1]))
output$plot_main <- renderPlot(
plot_reactive(),
plot(plot_reactive()),
res = get_plot_dpi(),
height = p_height,
width = p_width
)

output$plot_modal <- renderPlot(
plot_reactive(),
plot(plot_reactive()),
res = get_plot_dpi(),
height = reactive(input$height_in_modal),
width = reactive(input$width_in_modal)
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test-plot_with_settings.R
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ testthat::test_that("plot_with_settings_srv set dimensions and download a png fi
})

testthat::test_that("plot_with_settings_srv expand no error", {
plot_with_settings_args[["plot_r"]] <- function() plot(1)
plot_with_settings_args[["plot_r"]] <- function() 1
shiny::testServer(
teal.widgets:::plot_with_settings_srv,
args = plot_with_settings_args,
Expand All @@ -444,7 +444,7 @@ testthat::test_that("plot_with_settings_srv expand no error", {
})

testthat::test_that("plot_with_settings_srv set dimensions and download a png file from modal", {
plot_with_settings_args[["plot_r"]] <- function() plot(1)
plot_with_settings_args[["plot_r"]] <- function() 1
shiny::testServer(
teal.widgets:::plot_with_settings_srv,
args = plot_with_settings_args,
Expand All @@ -466,7 +466,7 @@ testthat::test_that("plot_with_settings_srv set dimensions and download a png fi
})

testthat::test_that("plot_with_settings_srv returns the click ggplot2 functionalities metadata", {
plot_with_settings_args$plot_r <- function() plot(1)
plot_with_settings_args$plot_r <- function() 1
shiny::testServer(
teal.widgets:::plot_with_settings_srv,
args = plot_with_settings_args,
Expand Down
Loading