0

When I try to include the excellent esquisse shinymodule into a flexdashboard, the plots are not rendered.

The example below tries to translate the Shiny example from the help for use in a flexdashboard, but although it displays and reads the data (it displays the column names and these change when selecting the "cars" data), it does not update the chart menu neither does it render the plot.

How can I make the plots render when using the esquisse Shiny module?

---
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)
  )
 
  
```
Lod
  • 609
  • 7
  • 19
  • Something is not rendering when the first label is placed in the first box. Never heard of the esquisse package but it's very interesting. May I suggest using 1 dataset first until you figure out the chart not displaying. I will research esquisse too. Thank you – Daniel_j_iii Apr 29 '21 at 12:18
  • my first thought was that the reactivity was not working, but given that the column names change upon selecting another dataset, it works to some extent. Also,if you change the header to TRUE in the above reprex, you can select a dataset in the environment. – Lod Apr 29 '21 at 12:54
  • the log below the output window shows ` Values: code_filters, code_plot, data Readonly: FALSE ` and normally when you add vars it suggests applicable plots (where the auto icon is). – Lod Apr 29 '21 at 12:56
  • @Lod Did you found a solution for this? – user3148607 Jan 21 '22 at 03:16

1 Answers1

1

I have put esquisse_ui() function into renderUI() function and it works fine. Give it a try.

Full example:

```{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
    )
)
```