我正在开发一个 R 闪亮应用程序,它使用多个 html 小部件,特别是networkD3、d3heatmap和chorddiag。
这些小部件单独工作正常。但是,在同一页面中使用它们会在它们应该出现的地方留下空白。
这是显示错误的可重现代码。在 UI 中注释绘图行,您将看到绘图出现和消失..
我非常感谢你的帮助!
# libraries
library(shiny)
library(d3heatmap)
library(chorddiag)
library(networkD3)
# Server
server <- function(input, output) {
# create heatmap
output$heatmap <- renderD3heatmap({
d3heatmap(mtcars, scale = "column", colors = "Spectral")
})
# create chord diagram
output$chord <- renderChorddiag({
m <- matrix(c(11975, 5871, 8916, 2868,1951, 10048, 2060, 6171, 8010, 16145, 8090, 8045,1013, 990, 940, 6907),
byrow = TRUE, nrow = 4, ncol = 4)
haircolors <- c("black", …Run Code Online (Sandbox Code Playgroud) 我有这个可缩放的热图,放大或缩小时看起来太慢了。有没有什么可以让它更快/更流畅,或者它的积分太多了,这是我能拥有的最好的。我想知道是否有一些技巧可以让浏览器更轻,同时保持工具提示等增强功能。或者也许我的代码处理缩放功能不是很好。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<style>
.axis text {
font: 10px sans-serif;
}
.axis path,
.axis line {
fill: none;
stroke: #000000;
}
.x.axis path {
//display: none;
}
.chart rect {
fill: steelblue;
}
.chart text {
fill: white;
font: 10px sans-serif;
text-anchor: end;
}
#tooltip {
position:absolute;
background-color: #2B292E;
color: white;
font-family: sans-serif;
font-size: 15px;
pointer-events: none; /*dont trigger events on the tooltip*/
padding: 15px 20px 10px 20px;
text-align: center;
opacity: 0;
border-radius: 4px;
} …Run Code Online (Sandbox Code Playgroud)我正在尝试向我的 Shiny 应用程序添加交互式热图,但我也有使用 ggiraph 的交互式图表。我目前正在使用 d3heatmap 包,但热图未在应用程序中呈现。我创建了一个玩具示例来说明这一点:
library(shiny)
library(ggiraph)
library(d3heatmap)
ui <- fluidPage(
d3heatmapOutput('d3'),
ggiraphOutput('gg')
)
server <- function(input, output, session) {
# Create heatmap
output$d3 <- renderD3heatmap({
d3heatmap(matrix(1:100, nrow = 100, ncol = 100))
})
# Create ggiraph
output$gg <- renderggiraph({
p <- ggplot(iris, aes(x = Sepal.Length, y = Petal.Width,
color = Species, tooltip = iris$Species) ) +
geom_point_interactive()
ggiraph(code = {print(p)})
})
}
shinyApp(ui = ui, server = server)
Run Code Online (Sandbox Code Playgroud)
总之,只有 ggiraph 渲染,但热图没有。但是,如果您注释掉 ggiraph 代码,则会呈现热图。我尝试切换加载包的顺序,但这仍然不起作用。
我目前在 R 3.2.2 上运行(我必须使用这个版本,因为公司服务器只在这个版本上运行,我的经理和我都没有更新它的权限)。我尝试下载 …
d3heatmap ×3
r ×2
shiny ×2
d3.js ×1
ggiraph ×1
htmlwidgets ×1
javascript ×1
networkd3 ×1
zooming ×1