-
Notifications
You must be signed in to change notification settings - Fork 15
/
graph.js.tmpl
32 lines (27 loc) · 1.1 KB
/
graph.js.tmpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="//d3js.org/d3.v5.min.js"></script>
<script src="https://unpkg.com/viz.js@1.8.1/viz.js" type="application/javascript"></script>
<script src="https://unpkg.com/d3-graphviz@2.6.0/build/d3-graphviz.min.js"></script>
<script>
var transition = d3.transition("t")
.duration(500)
.ease(d3.easeLinear);
var graphviz = d3.select("#graph").graphviz(false);
function render() {
var graph_data = $.ajax({
url: "http://" + controller_addr + "/simple_graph",
dataType: "text",
success: function(data) {
$("#error-msg").removeClass("show");
graphviz.transition(transition).renderDot(data);
},
error: function(e) {
$("#error-msg").html("AJAX request to controller API failed: " + e.statusText).addClass("show");
graphviz.transition(transition).renderDot('digraph {}');
}
});
}
setInterval(function() {
render();
}, 1000);
</script>