r - 同一个闪亮页面上的两个 wordcloud2
问题描述
我正在尝试将两个 wordcloud2 放在我闪亮的仪表板上,而第二个没有显示
当我检查页面时,它们都在正文中
我的脚本
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)
(将来,在发布代码问题之前,请确保提供的代码可以运行,除非问题出在代码本身)
推荐阅读
- openstack - 从 openstack 环境收集指标并在 grafana 中显示
- java - 来自 ArrayList<> 的实体对象上的 JAVA 泛型
- timestamp - 在 aws athena 中按日期时间查询解析 alb 日志时出错
- javascript - 显示和隐藏选项通常被捕获到表中的单个 Id
- android - 不要使用 Android 导航组件在 backstack 中包含片段
- d3.js - 应用交叉过滤器时,有没有办法为 dc.js 中的热图中未选中的框设置默认颜色?
- azureservicebus - 是否可以将 Azure Service Bus 的指标信息转发到 Azure Application Insights?
- javascript - 创建一个可以作为参数传递给 swiper JS 的对象
- android - 如何在 Android 上使用 RGB_565 从 ByteBuffer 获取像素的 RGB
- apache-spark - 在 pyspark 数据框中删除连续重复项