簡體   English   中英

同一閃亮頁面上的兩個wordcloud2

[英]Two wordcloud2 on the same shiny page

我試圖將兩個wordcloud2放到我閃亮的dahboard中,而第二個未顯示

當我檢查頁面時它們都在體內

在此處輸入圖片說明

我的劇本

library(wordcloud2)
library(shinydashboardd)
# Global variables can go here
n <- 1

# Define the UI
ui <- dashboardPage(
   box(wordcloud2Output('wordcloud2')),
   box(wordcloud2Output('wordcloud3'))
)


# Define the server code
server <- function(input, output) {
  output$wordcloud2 <- renderWordcloud2({
    wordcloud2(demoFreq)
  })

  output$wordcloud3 <- renderWordcloud2({
    wordcloud2(demoFreq)
  })

}
shinyApp(ui = ui, server = server)

編輯:當我使用答案腳本時,沒有第二個wordcloud屏幕快照

在此處輸入圖片說明

兩個wordcloud div的html輸出

<!DOCTYPE html>
<html>
<head>

  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <script type="application/shiny-singletons"></script>
  <script type="application/html-dependencies">json2[2014.02.04];jquery[1.12.4];shiny[1.2.0];htmlwidgets[1.3];wordcloud2[0.0.1];wordcloud2-binding[0.2.1];bootstrap[3.3.7]</script>
<script src="shared/json2-min.js"></script>
<script src="shared/jquery.min.js"></script>
<link href="shared/shiny.css" rel="stylesheet" />
<script src="shared/shiny.min.js"></script>
<script src="htmlwidgets-1.3/htmlwidgets.js"></script>
<link href="wordcloud2-0.0.1/wordcloud.css" rel="stylesheet" />
<script src="wordcloud2-0.0.1/wordcloud2-all.js"></script>
<script src="wordcloud2-0.0.1/hover.js"></script>
<script src="wordcloud2-binding-0.2.1/wordcloud2.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="shared/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
<script src="shared/bootstrap/js/bootstrap.min.js"></script>
<script src="shared/bootstrap/shim/html5shiv.min.js"></script>
<script src="shared/bootstrap/shim/respond.min.js"></script>

</head>

<body>
  <div class="container-fluid">
    <div id="wordcloud2" style="width:100%; height:400px; " class="wordcloud2 html-widget html-widget-output"></div>
    <div id="wordcloud3" style="width:100%; height:400px; " class="wordcloud2 html-widget html-widget-output"></div>
  </div>
</body>

</html>

在此屏幕截圖上沒有任何影響力; 繼承第二個wordcloud

在此處輸入圖片說明

我沒有遇到任何與此有關的問題。 我無法運行您的代碼,因為它存在一些錯誤(您寫了shinydashboardd而不是shinydashboard ,並且UI也無法運行,因為dashboardPage()函數不能接受兩個框作為參數),但是如果我修復了這些錯誤它工作正常:

library(wordcloud2)
library(shiny)

ui <- fluidPage(
        wordcloud2Output('wordcloud2'),
        wordcloud2Output('wordcloud3')
)

server <- function(input, output) {
        output$wordcloud2 <- renderWordcloud2({
                wordcloud2(demoFreq)
        })

        output$wordcloud3 <- renderWordcloud2({
                wordcloud2(demoFreq)
        })
}

shinyApp(ui = ui, server = server)

(以后,在發布代碼問題之前,請確保所提供的代碼可以運行,除非問題出在代碼本身之外)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM