esquisse 包中的 ggplot 图未在 flexdashboard 中呈现

ggplot plot from esquisse package not rendering in flexdashboard

当我尝试将优秀的 esquisse shinymodule 包含到 flexdashboard 中时,绘图没有呈现。

下面的示例尝试将帮助中的 Shiny 示例翻译成在 flexdashboard 中使用,但是尽管它显示和读取数据(它显示列名并且这些在选择“汽车”数据时发生变化),它不更新图表菜单,也不渲染图表。

如何在使用 esquisse Shiny 模块时渲染绘图?

---
title: "Quick demo for Data"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
runtime: shiny
---


   
Test
=====================================     
```{r}


library(esquisse)
# shiny inputs defined here
radioButtons(
    inputId = "data", 
    label = "Data to use:", 
    choices = c("iris", "mtcars"))

checkboxGroupInput(
    inputId = "aes", 
    label = "Aesthetics to use:", 
    choices = c(
      "fill", "color", "size", "shape", 
      "weight", "group", "facet", "facet_row", "facet_col"
    ),
    selected = c("fill", "color", "size", "facet"))

  esquisse_ui(
    id = "esquisse", 
    header = FALSE, # dont display gadget title
    container = esquisseContainer(height = "700px"))
  
  
  data_rv <- reactiveValues(data = iris, name = "iris")
  
  observeEvent(input$data, {
    if (input$data == "iris") {
      data_rv$data <- iris
      data_rv$name <- "iris"
    } else {
      data_rv$data <- mtcars
      data_rv$name <- "mtcars"
    }
  })
  
  esquisse_server(
    id = "esquisse", 
    data_rv = data_rv, 
    default_aes = reactive(input$aes)
  )
 
  
```

我已将 esquisse_ui() 函数放入 renderUI() 函数中,它工作正常。试一试。

完整示例:

```{r}
esqSData <- reactiveValues(data = mydata, name = "My Data")

esquisse_server(
  id = "esquisse",
  data_rv = esqSData,
  import_from = c("env", "file", "copypaste", "googlesheets") )

renderUI(
  esquisse_ui(
    id = "esquisse",
    header = TRUE,
    container = esquisseContainer(),
    controls = c("labs", "parameters", "appearance", "filters", "code"),
    insert_code = FALSE
    )
)
```