Как исключить параметры в блестящей закладке? - PullRequest
0 голосов
/ 15 января 2019

Я создаю панель мониторинга и хочу исключить некоторые параметры из закладок.

Вот MWE:

library(shiny)

# Define UI for application that draws a histogram
ui <- function(request) {
    fluidPage(

        # Application title
        titlePanel("Old Faithful Geyser Data"),

        # Sidebar with a slider input for number of bins 
        sidebarLayout(
            sidebarPanel(
                sliderInput("bins",
                            "Number of bins:",
                            min = 1,
                            max = 50,
                            value = 30),
                selectInput(
                    "y",
                    "Year:",
                    choices = 1990:2000,
                    selected = 1990,
                    selectize = TRUE
                )
            ),

            # Show a plot of the generated distribution
            mainPanel(
                plotOutput("distPlot")
            )
        )
    )
}

# Define server logic required to draw a histogram
server <- function(input, output, session) {

    output$distPlot <- renderPlot({
        # generate bins based on input$bins from ui.R
        x    <- faithful[, 2]
        bins <- seq(min(x), max(x), length.out = input$bins + 1)

        # draw the histogram with the specified number of bins
        hist(x, breaks = bins, col = 'darkgray', border = 'white')
    })

    observe({
        # Trigger this observer every time an input changes
        # strip shiny related URL parameters
        grep("selectized", reactiveValuesToList(input), value = TRUE, invert = TRUE)
        session$doBookmark()
    })

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

# Run the application 
enableBookmarking("url")
shinyApp(ui = ui, server = server)

Работает и возвращает этот действительный (и редактируемый) URL http://127.0.0.1:7449/?_inputs_&bins=30&y="1996"&y-selectized=""

Я хотел бы проигнорировать параметр "selectized" и исключить его из закладки, или, по крайней мере, удалить его из URL, если он вообще ничего не влияет. Я не могу понять, почему grep здесь не работает.

1 Ответ

0 голосов
/ 19 апреля 2019

Вы можете использовать setBookmarkExclude() в функции вашего сервера (тогда grep() больше не требуется):

setBookmarkExclude("y-selectized")
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...