<!DOCTYPE html>
<html><head>
<meta charset="utf-8">
<style>
.node circle {
  fill: #fff;
  stroke: steelblue;
  stroke-width: 1.5px;
}

.node {
  font: 10px sans-serif;
}

.link {
  fill: none;
  stroke: #ccc;
  stroke-width: 1.5px;
}
</style>
</head>
<body>
<h3>{{ title }}</h3>
 {{ time }} 
  <a href="{{ top }}">top</a>
  <a href="{{ json_url | safe }}">json</a>
 {% for item in items %}
  <a href="{{ item.href }}">{{ item.key }}</suia>
 {% endfor %}<br/>
  <a href="http://bl.ocks.org/mbostock/4063550">Thanks</a>
<script>var jsondata ="{{ json_url }}", WIDTH=640, HEIGHT= 740;</script>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="/static/ecflow.js"></script><br/>
<script>

var diameter = 960;

var tree = d3.layout.tree()
    .size([360, diameter / 2 - 120])
    .separation(function(a, b) { return (a.parent == b.parent ? 1 : 2) / a.depth; });

var diagonal = d3.svg.diagonal.radial()
    .projection(function(d) { return [d.y, d.x / 180 * Math.PI]; });

var svg = d3.select("body").append("svg")
    .attr("width", diameter)
    .attr("height", diameter + 150)
  .append("g")
    .attr("transform", "translate(" + diameter / 2 + "," + diameter / 2 + ")");

//d3.json("{{ jsondata | safe }}", function(error, root) {
d3.json(jsondata, function(error, root) {
//d3.json("flare.json", function(error, root) {
  var nodes = tree.nodes(root),
      links = tree.links(nodes);

  var link = svg.selectAll(".link")
      .data(links)
    .enter().append("path")
      .attr("class", "link")
      .attr("d", diagonal);

  var node = svg.selectAll(".node")
      .data(nodes)
    .enter().append("g")
      .attr("class", "node")
      .attr("transform", function(d) { return "rotate(" + (d.x - 90) + ")translate(" + d.y + ")"; })

  node.append("circle")
      .attr("r", 4.5)
.style("stroke", function(d) { 
if (d._status) return colour(d);
return d.children ? color(d.name):"steelblue";})
;

  node.append("text")
      .attr("dy", ".31em")
      .attr("text-anchor", function(d) { return d.x < 180 ? "start" : "end"; })
      .attr("transform", function(d) { return d.x < 180 ? "translate(8)" : "rotate(180)translate(-8)"; })
      .text(function(d) { return d.name; });
});

d3.select(self.frameElement).style("height", diameter - 150 + "px");

</script>
</body>
</html>
