Integration among Shiny Flexdashboard and shinyAmBarCharts

为君一笑 提交于 2020-03-25 18:20:27

问题


I'm trying to insert a shinyAmBarCharts chart within a flexdashboard with Shiny runtime. The final goal would be to use the modifiable chart as an input to other charts/models. So far I've been unsuccessful, because the amBarChart does not render in the dashboard. This is a sample code:

---
title: "shinyAmBarCharts"
output: 
  flexdashboard::flex_dashboard:
  orientation: columns
  vertical_layout: fill
 runtime: shiny
---

 ```{r setup, include=FALSE}

 library(flexdashboard)
 library(shiny)
 library(shinyAmBarCharts)
 library(tidyr)


set.seed(666)
df0 <- data.frame(
species = rep(c("sorgho","poacee","banana","triticum"), each = 3),
condition = rep(c("normal", "stress", "Nitrogen"), 4),
 value = rpois(12, 10)
 )
df1 <- spread(df0, condition, value)


output[["data"]] <- renderPrint({
input[["mygroupedbarchart"]]
 })

 output[["change"]] <- renderPrint({ input[["mygroupedbarchart_change"]] })

```

Column {data-width=650}
-----------------------------------------------------------------------

### Chart A

 ```{r}
 fluidPage(

       amBarChart(
         "mygroupedbarchart", data = df1, height = "400px",
         category = "species", value = c("normal", "stress", "Nitrogen"),
         valueNames = c("Normal", "Stress", "Nitrogen"),
         minValue = 0, maxValue = 20,
         draggable = c(FALSE, FALSE, TRUE),
         theme = "dark", backgroundColor = "#30303d",
         columnStyle = list(fill = c("darkmagenta", "darkred", "gold"),
                            stroke = "#cccccc", 
                            cornerRadius = 4),
         chartTitle = list(text = "Grouped bar chart", 
                           fontSize = 23, 
                           color = "firebrick"),
         xAxis = list(title = list(text = "Species", 
                                   fontSize = 21, 
                                   color = "silver"),
                      labels = list(color = "whitesmoke", 
                                    fontSize = 17)),
         yAxis = list(title = list(text = "Value", 
                                   fontSize = 21, 
                                   color = "silver"),
                      labels = list(color = "whitesmoke", 
                                    fontSize = 14)),
         columnWidth = 90,
         caption = list(text = "[font-style:italic]shinyAmBarCharts[/]", 
                        color = "yellow"),
         gridLines = list(color = "whitesmoke", 
                          opacity = 0.4, 
                          width = 1),
         tooltip = list(text = "[bold;font-style:italic]{name}: {valueY}[/]", 
                        labelColor = "#101010", 
                        backgroundColor = "cyan", 
                        backgroundOpacity = 0.7)
       )
       )
```

 Column {data-width=350}
  -----------------------------------------------------------------------

 ### Chart B

 ```{r}

        verbatimTextOutput("data")


  ```

 ### Chart C

 ```{r}
       verbatimTextOutput("change")

 ```

that I have basically copied from these places:

  • https://github.com/stla/shinyAmBarCharts
  • Draggable interactive bar chart Rshiny.

I' ve tried the inline shiny-app solution from the flexdashboard web page (https://rmarkdown.rstudio.com/flexdashboard/shiny.html#inline_applications), but in this case I do not know how to re-use the changes made to the chart as an input to other part of the flexdashboard.

Any help would be much appreciated.

来源:https://stackoverflow.com/questions/60835547/integration-among-shiny-flexdashboard-and-shinyambarcharts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!