このコードを作成してください。私はチャートを2度描くことができません。 このシーケンスのテキストボックスの入力値を試してください。RシャイニーダイナミックUIでgooglevisグラフを2回レンダリングできません
- 1、2及び6
- 1,6及び2
実施例1について、それは一度だけグラフをプロットします。例2の場合は、2度しかプロットされません(異なるグラフなので) これは、ユーザーが何度も何度も働くようにするためのヒントです。
ui <- fluidPage(
tagList(textInput(inputId = "textbox", label = NULL,value = ""),actionButton("go", "Go"),uiOutput("ui")))
server <- function(input, output) {
observeEvent(input$go, {
output$plot1 <- renderGvis({
df <- data.frame(country=c("US", "GB", "BR"),
val1=c(10,33,44),
val2=c(23,122,342))
Sys.sleep(0.3)
gvisBarChart(df, xvar="country", yvar=c("val1", "val2"),
options=list(isStacked=TRUE, height = 300, width = 400))
})
output$plot2 <- renderGvis({
df <- data.frame(country=c("IND", "RUS", "BR"),
val1=c(10,3333,244),
val2=c(2344,122,342))
Sys.sleep(0.3)
gvisBarChart(df, xvar="country", yvar=c("val1", "val2"),
options=list(isStacked=TRUE, height = 300, width = 400))
})
output$ui <- renderUI({
if(isolate(as.numeric(input$textbox)) %in% c(1,2,3)){
box(title = "ABC", width = 10, height = 550, htmlOutput("plot1",height = 500))
}else{
box(title = "DEF", width = 4, height = 550, htmlOutput("plot2",height = 500))
}
})
})
}