2017-11-16 27 views
7

के साथ काम नहीं करता है मैं चमकदार राज्य बुकमार्किंग के साथ flexdashboard को गठबंधन करने की कोशिश कर रहा हूं। जब (डॉक्स से उदाहरण) अकेले इस्तेमाल किया चमकदार एप्लिकेशन ठीक काम करता है, लेकिन जब flexdasboard में डाल दिया, यूआरएल अपडेट नहीं किया गया:फ्लेक्सडैशबोर्ड चमकदार यूआरएल राज्य

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

```{r setup, include=FALSE} 
library(flexdashboard) 
``` 

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

### Chart A 

```{r} 

shinyApp(
    ui=function(req) { 
    fluidPage(
     textInput("txt", "Text"), 
     checkboxInput("chk", "Checkbox") 
    ) 
    }, 
    server=function(input, output, session) { 
    observe({ 
     # Trigger this observer every time an input changes 
     reactiveValuesToList(input) 
     session$doBookmark() 
    }) 
    onBookmarked(function(url) { 
     updateQueryString(url) 
    }) 
    }, 
    enableBookmarking = "url" 
) 

``` 

यह और भी संभव है? स्टैंडअलोन निष्पादन की तुलना में:

shinyApp(
    ui=function(req) { 
    fluidPage(
     textInput("txt", "Text"), 
     checkboxInput("chk", "Checkbox") 
    ) 
    }, 
    server=function(input, output, session) { 
    observe({ 
     # Trigger this observer every time an input changes 
     reactiveValuesToList(input) 
     session$doBookmark() 
    }) 
    onBookmarked(function(url) { 
     updateQueryString(url) 
    }) 
    }, 
    enableBookmarking = "url" 
) 

यह onBookmarked (और onBookmark, onRestore और onRestored की तरह समान घटनाओं) की तरह दिखता है कभी नहीं ट्रिगर कर रहे हैं।

उत्तर

6

आर मार्कडाउन दस्तावेज़ों में एम्बेडेड चमकदार ऐप्स में बुकमार्किंग समर्थित नहीं है।

यहाँ चर्चा देखें: https://github.com/rstudio/shiny/pull/1209#issuecomment-227207713

ऐसा लगता है कि यह तकनीकी रूप से संभव है, लेकिन ऐसा करने के लिए मुश्किल है। उदाहरण के लिए, दस्तावेज़ में एम्बेडेड एकाधिक ऐप्स होने पर क्या होता है? साथ ही, ऐप्स को आईफ्रेम के रूप में एम्बेड किया गया है, इसलिए इन ऐप्स को अपने मूल विंडो के यूआरएल को एक्सेस/संशोधित करने के लिए कुछ तारों को करने की आवश्यकता होगी।


हालांकि, बुकमार्किंग एम्बेडेड चमकदार घटकों (पूर्ण अनुप्रयोगों के बजाय) के साथ काम करती है।

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

```{r setup, include=FALSE} 
knitr::opts_chunk$set(echo = FALSE) 
enableBookmarking("url") 
``` 

```{r, include=FALSE} 
observe({ 
    reactiveValuesToList(input) 
    session$doBookmark() 
}) 

onBookmarked(function(url) { 
    updateQueryString(url) 
}) 

output$content <- renderUI({ 
    tagList(
    textInput("txt", "Text"), 
    checkboxInput("chk", "Checkbox") 
) 
}) 
``` 

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

### Chart A 

```{r} 
fluidPage(
    uiOutput("content"), 
    selectInput("sel", label = "Select", choices = c(10, 20, 30), selected = 10) 
) 
``` 

तुम भी, Prerendered Shiny Documents उपयोग कर सकते हैं, हालांकि बुकमार्क करने के लिए 100% यूआई के बाद से ही काम नहीं होता पूर्व प्रदान की गई है। किसी भी स्थिर यूआई को bookmarking callbacks के साथ मैन्युअल रूप से पुनर्स्थापित करना होगा, लेकिन डायनामिक UI को ठीक से पुनर्स्थापित किया जाएगा।

--- 
title: "Untitled" 
output: 
    flexdashboard::flex_dashboard: 
    orientation: columns 
    vertical_layout: fill 
runtime: shiny_prerendered 
--- 

```{r setup, include=FALSE} 
knitr::opts_chunk$set(echo = FALSE) 
enableBookmarking("url") 
``` 

```{r, context="server"} 
observe({ 
    reactiveValuesToList(input) 
    session$doBookmark() 
}) 

onBookmarked(function(url) { 
    updateQueryString(url) 
}) 

# Static inputs are pre-rendered, and must be manually restored 
onRestored(function(state) { 
    updateSelectInput(session, "sel", selected = state$input$sel) 
}) 

# Dynamic inputs will be restored with no extra effort 
output$content <- renderUI({ 
    tagList(
    textInput("txt", "Text"), 
    checkboxInput("chk", "Checkbox") 
) 
}) 
``` 

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

### Chart A 

```{r} 
fluidPage(
    uiOutput("content"), 
    selectInput("sel", label = "Select", choices = c(10, 20, 30), selected = 10) 
) 
```