Interactive graphviz in Shiny, via r2d3 ... help with javascript dependencies


I'm working with a goal of being able to dynamically interact with graphviz plots in a Shiny app.

I got basic r2d3 examples running without any trouble.

But to fully do the above, I think I need some additional library code. d3-graphviz appears to have the functionality I might need to do this:

What I don't know how to do is include the d3-graphviz dependency in my code. Unfortunately I'm completely new to javascript and I can't figure out the right syntax to express it ... perhaps it uses htmlDependency()?

ui <- fluidPage(

server <- function(input, output) {
  output$d3 <- renderD3({
      script = "gv1.js"
   ###   , dependencies = {{Here's where I need help}}  ####

When I look at d3-graphiz examples in javascript, they look like:

<!DOCTYPE html>
<meta charset="utf-8">
<script src="//"></script>
<script src="" type="javascript/worker"></script>
<script src=""></script>
<div id="graph" style="text-align: center;"></div>
    .renderDot('digraph  {a -> b}');



Can anyone provide any guidance about how to inject those

<script src=...> 

into my Shiny app, so that it recognizes d3-graphviz?


Yea, the dependencies argument expects a list of htmltools::htmlDependency() objects. If you want, you can have those dependencies use external links like this:


deps <- list(
    name = "d3",
    version = "4.0",
    src = list(href = ""),
    script = "d3.v4.min.js"
    name = "viz.js",
    version = "1.8.1",
    src = list(href = ""),
    script = "viz.js"
    name = "d3-graphviz",
    version = "2.6.1",
    src = list(href = ""),
    script = "build/d3-graphviz.js"

r2d3(..., dependencies = deps)

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.