code export works!
Some checks are pending
pkgdown.yaml / pkgdown (push) Waiting to run

This commit is contained in:
Andreas Gammelgaard Damsbo 2025-04-09 12:31:08 +02:00
commit 347490605f
No known key found for this signature in database
20 changed files with 573 additions and 538 deletions

View file

@ -86,7 +86,10 @@ data_visuals_ui <- function(id, tab_title = "Plots", ...) {
),
bslib::nav_panel(
title = tab_title,
shiny::plotOutput(ns("plot"))
shiny::plotOutput(ns("plot"),height = "70vh"),
shiny::tags$br(),
shiny::h4("Plot code:"),
shiny::verbatimTextOutput(outputId = ns("code_plot"))
)
)
}
@ -109,7 +112,8 @@ data_visuals_server <- function(id,
rv <- shiny::reactiveValues(
plot.params = NULL,
plot = NULL
plot = NULL,
code=NULL
)
# ## --- New attempt
@ -302,15 +306,26 @@ data_visuals_server <- function(id,
{
tryCatch(
{
shiny::withProgress(message = "Drawing the plot. Hold tight for a moment..", {
rv$plot <- create_plot(
data = data(),
parameters <- list(
type = rv$plot.params()[["fun"]],
x = input$primary,
y = input$secondary,
z = input$tertiary
)
shiny::withProgress(message = "Drawing the plot. Hold tight for a moment..", {
rv$plot <- rlang::exec(create_plot, !!!append_list(data(),parameters,"data"))
# rv$plot <- create_plot(
# data = data(),
# type = rv$plot.params()[["fun"]],
# x = input$primary,
# y = input$secondary,
# z = input$tertiary
# )
})
rv$code <- glue::glue("FreesearchR::create_plot(data,{list2str(parameters)})")
},
# warning = function(warn) {
# showNotification(paste0(warn), type = "warning")
@ -323,6 +338,10 @@ data_visuals_server <- function(id,
ignoreInit = TRUE
)
output$code_plot <- shiny::renderPrint({
cat(rv$code)
})
output$plot <- shiny::renderPlot({
shiny::req(rv$plot)
rv$plot