r - ggplot plot from esquisse package not rendering in flexdashboard
问题描述
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)
)
```
解决方案
我已将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
)
)
```
推荐阅读
- python - 彩色输出 python
- ruby - 在 Ruby 中用引号将数组的输出包装到 CSV 转换
- python-2.7 - 从 os.popen('cmd').read() 接收长度为 0 的字符串
- php - 使用 DataFixtures 在 WebTestCase 上进行 phpUnitTest 后的 TearDown 数据库
- maven - maven checkstyle 插件创建一个输出文件并且检查它失败
- linux - 服务
start 无法启动服务,servlet.log 中没有任何错误 - linux - 基于标签(声明式语法)触发从 bitbucket 到 Jenkins 的构建
- asp.net-core-2.0 - ASPNET Core OIDC 关联失败
- bash - 类 PATH 变量的 bash 大括号扩展
- c# - 在 CSS 中添加类