Skip to content

Instantly share code, notes, and snippets.

@Capstan
Last active May 23, 2018 16:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Capstan/a3279ce28fbe2dffa6219847f2761fd4 to your computer and use it in GitHub Desktop.
Save Capstan/a3279ce28fbe2dffa6219847f2761fd4 to your computer and use it in GitHub Desktop.
Render loaded .dot file
license: Apache-2.0
<!DOCTYPE html>
<meta charset="utf-8">
<body>
<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>
<div id="graph" style="text-align: center;"></div>
<script>
<!-- This is a (failed) attempt to inhibit stack overflow. -->
Error.stackTraceLimit = Infinity
var graphviz = d3.select("#graph").graphviz()
<!-- Increase memory available to avoid OOM -->
.totalMemory(Math.pow(2, 27))
.transition(function () {
return d3.transition("main")
.ease(d3.easeLinear);
})
.logEvents(true)
.on("initEnd", readDotAndRender);
function readDotAndRender() {
var filename = "simple.dot"
// var filename = "really_large_not_in_this_gist.dot"
fetch(filename, {mode:'no-cors'})
.then(response => response.text())
.then(text => graphviz.renderDot(text));
}
</script>
</body>
digraph m { a; b; a->b; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment