magjac / d3-graphviz

Graphviz DOT rendering and animated transitions using D3
BSD 3-Clause "New" or "Revised" License
1.69k stars 103 forks source link

useWorker = false has a TypeError #60

Closed Capstan closed 6 years ago

Capstan commented 6 years ago

d3.select("#graph").graphviz(false); yields the following error:

Uncaught TypeError: Viz is not a function
  at Graphviz.initViz (d3-graphviz.js:796)
  at new Graphviz (d3-graphviz.js:1931)
  at Selection.selection_graphviz [as graphviz] (d3-graphviz.js:1974)

This is with the following imports:

<script src="https://d3js.org/d3.v5.js"></script>
<script src="https://unpkg.com/viz.js@1.8.1/viz.js" type="javascript/worker"></script>
<script src="https://unpkg.com/d3-graphviz@2.1.0/build/d3-graphviz.js"></script>

It appears Viz is undefined.

magjac commented 6 years ago

Sorry, the README was a bit unclear regarding this. I've updated it now. See https://github.com/magjac/d3-graphviz#defining-the-vizjs-script-tag.

If you're not using a web worker, the script type must be application/javascript:

<script src="https://unpkg.com/viz.js@1.8.1/viz.js" type="application/javascript"></script>

Thanks for submitting this issue. If you are using this library, don't forget to Watch it to stay tuned for updates or even Star it if you like it.

You can also use Stack Overflow tags d3.js & graphviz or the d3-graphviz Slack to ask for help. Although I make an effort to assist everyone that asks, I am not always available to provide help promptly or directly.