1
我試圖實現一個簡單的閃亮的應用程序與兩個依賴小部件。首先一切正常,但是當我更改大陸值,即地圖消失時出現問題。你知道我應該添加什麼來避免這個障礙嗎?googleVis無法正常工作與兩個依賴小部件閃亮
ui.R
library(shiny)
shinyUI(fluidPage(
sidebarLayout(
sidebarPanel(
selectInput("continent", "Select the continent: ",
c("Africa", "America", "Asia","Europe"),
selected = "Africa"),
uiOutput('server_country')
),
mainPanel(
htmlOutput("map"))
)
))
server.R
library(shiny)
library(googleVis)
continent_countries <- list(Africa = c("Tunisia"),
America = c("Argentina","Brazil"),
Asia = c("China","Japan","India"),
Europe = c("France","Germany","Italy","Spain"))
shinyServer(function(input, output) {
output$server_country <- renderUI({
choosen_countries <- input$continent
selectizeInput('out_country', "Select the countries:",
choices = continent_countries[[choosen_countries]])
})
continent_code <- reactive({
switch(input$continent,
Africa = "002",
America = "019",
Asia = "142",
Europe = "150")
})
output$map <- renderGvis({
if(is.null(input$out_country))
return()
validate(
need(length(input$out_country) > 0, "Please select at least onecountry"))
#
plot.dataset <- data.frame(countries = input$out_country, value = 5)
gvisGeoChart(plot.dataset, locationvar = "countries",sizevar = "value",
options = list(region = continent_code(),displayMode = "regions"))
})
})
有可能是一種方式得到它只打了一次服務器,但我不會擔心太硬了。 –
是的,但事實並非如此。我想使用輸入更新的概念,兩個相關的小部件。 – Nicolabo
這裏的情況並非如此?這絕對是服務器兩次。當我添加延遲它工作正常。 –