First, I would like to thank youto provide us this excellent package. While using this plot function along with ggiraph, I figured out that I can not visualize the streamgraph plot in Shiny App, although I could see both the plots on RStudio. Also, I do not see any error message only the output plot area is blank, nothing rendered! When commenting out (#ggiraphOutput('Bubble')) I can again see the streampgraph output. Has any one encounter similar experience and how to solve the issue?
For your reference, here is the code one can try in Shiny.
Thanks a lot for your help.
library(shiny)
library(dplyr)
library(babynames)
library(streamgraph)
library(packcircles)
library(ggplot2)
library(viridis)
library(ggiraph)
ui <- shinyUI(
mainPanel(
streamgraphOutput("streamPlot"),
ggiraphOutput('Bubble')
)
)
server <- shinyServer(function(input, output) {
bn <- babynames %>%
filter(grepl("^Kr", name)) %>%
group_by(year, name) %>%
tally(wt=n)
output$streamPlot <- renderStreamgraph({
browser()
streamgraph(bn, "name", "nn", "year", interactive=FALSE)
})
output$Bubble <- renderggiraph({
# Create data
browser()
data=data.frame(group=paste("Group_", sample(letters, 70, replace=T), sample(letters, 70, replace=T), sample(letters, 70, replace=T), sep="" ), value=sample(seq(1,70),70))
# Add a column with the text you want to display for each bubble:
data$text=paste("name: ",data$group, "\n", "value:", data$value, "\n", "You can add a story here!")
# Generate the layout
packing <- circleProgressiveLayout(data$value, sizetype='area')
data = cbind(data, packing)
dat.gg <- circleLayoutVertices(packing, npoints=50)
# Make the plot with a few differences compared to the static version:
p=ggplot() +
geom_polygon_interactive(data = dat.gg, aes(x, y, group = id, fill=id, tooltip = data$text[id], data_id = id), colour = "black", alpha = 0.6) +
scale_fill_viridis() +
geom_text(data = data, aes(x, y, label = gsub("Group_", "", group)), size=2, color="black") +
theme_void() +
theme(legend.position="none", plot.margin=unit(c(0,0,0,0),"cm") ) +
coord_equal()
ggiraph(ggobj = p, width_svg = 7, height_svg = 7)
})
})
shinyApp(ui, server)
First, I would like to thank youto provide us this excellent package. While using this plot function along with ggiraph, I figured out that I can not visualize the streamgraph plot in Shiny App, although I could see both the plots on RStudio. Also, I do not see any error message only the output plot area is blank, nothing rendered! When commenting out (#ggiraphOutput('Bubble')) I can again see the streampgraph output. Has any one encounter similar experience and how to solve the issue? For your reference, here is the code one can try in Shiny. Thanks a lot for your help.