statnet / ndtv

ndtv: Network Dynamic Temporal Visualizations in R
https://cran.r-project.org/web/packages/ndtv/index.html
46 stars 5 forks source link

renderNdtvAnimationWidget() does not work if your network does not contain temporal information #48

Open Dekermanjian opened 2 years ago

Dekermanjian commented 2 years ago

renderNdtvAnimationWidget() will return a blank iFrame of the widget if you do not have any temporal information. Is there any way to render in a Shiny app a network constructed by render.d3movie() where animation output controls are disabled by default?

skyebend commented 2 years ago

I have not tried inside a shiny app, but the ndtv-d3 vignette has an example of rendering a static network that can still be interacted with in the browser without the timeline controls:

data(emon)
totalStaff<-emon[[5]]%v%'Volunteer.Staff'+emon[[5]]%v%'Paid.Staff'
sizeScale<-ifelse(is.na(totalStaff),1,totalStaff/100+1)
render.d3movie(emon[[5]],
    vertex.tooltip=paste("<strong>",emon[[5]]%v%'vertex.names',"</strong><br>",
      "Decision Rank Score:",emon[[5]]%v%'Decision.Rank.Score',"<br>",
      "Command Rank Score:",emon[[5]]%v%'Command.Rank.Score',"<br>",
      "Formalization:",emon[[5]]%v%'Formalization',"<br>",
      "Location:",emon[[5]]%v%'Location',"<br>",
      "Sponsorship:",emon[[5]]%v%'Sponsorship',"<br>"),
    vertex.cex=sizeScale,
    vertex.col=grDevices::adjustcolor(as.color(emon[[5]]%v%'Sponsorship'),alpha.f=0.5),
    edge.tooltip=paste('Frequency:',emon[[5]]%e%'Frequency'),
    edge.lwd='Frequency',
    edge.col='#00000055',
    )

It does seem like the html vignette intended to illustrate this functionality is not displaying correctly in the package, but you should be able to download and view in browser from https://github.com/statnet/ndtv/blob/master/ndtv_d3_vignette/ndtv-d3_vignette.html