Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Streamgraph not showing with other htmlwidget output in Shiny app #35

Open
amritrajpatra opened this issue Jan 30, 2019 · 1 comment
Open

Comments

@amritrajpatra
Copy link

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)
@akale1994
Copy link

Hello,

I am facing the same issue and I am stuck with it. Were you able to find any solution? Please do reply back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants