{% extends "shared/d3_base.html" %}




{% block custom_css %}



<style type="text/css" media="screen">


#chart, #header, #footer {
  position: absolute;
  top: 0;
}

#header, #footer {
  z-index: 1;
  display: block;
  font-size: 36px;
  font-weight: 300;
  text-shadow: 0 1px 0 #fff;
}

#header.inverted, #footer.inverted {
  color: #fff;
  text-shadow: 0 1px 4px #000;
}

#header {
  top: 80px;
  left: 140px;
  width: 1000px;
}

#footer {
  top: 680px;
  right: 140px;
  text-align: right;
}

rect {
  fill: none;
  pointer-events: all;
}

pre {
  font-size: 18px;
}

line {
  stroke: #000;
  stroke-width: 1.5px;
}

.string, .regexp {
  color: #f39;
}

.keyword {
  color: #00c;
}

.comment {
  color: #777;
  font-style: oblique;
}

.number {
  color: #369;
}

.class, .special {
  color: #1181B8;
}

a:link, a:visited {
  color: #000;
  text-decoration: none;
}

a:hover {
  color: #666;
}

.hint {
  position: absolute;
  right: 0;
  width: 1280px;
  font-size: 12px;
  color: #999;
}


.chart {
  display: block;
  margin: auto;
  margin-top: 60px;
  font-size: 11px;
}

rect {
  stroke: #eee;
  fill: #aaa;
  fill-opacity: .8;
}

rect.parent {
  cursor: pointer;
  fill: steelblue;
}

text {
  pointer-events: none;
}

</style>


{% endblock custom_css %}









{% block main_content %}


	<div class="row header">
		
		
		
			
		{% if TOTAL_CLASSES %}
			<a href="index.html" class="{% if thispage=="classes" %}active{% endif %}">Classes ({{TOTAL_CLASSES}})</a>&nbsp;&nbsp;
		{% endif %}
		
		{% if TOTAL_PROPERTIES %}
			<a href="properties.html" class="{% if thispage=="properties" %}active{% endif %}">Properties ({{TOTAL_PROPERTIES}})</a>&nbsp;&nbsp;
		{% endif %}
		
		{% if TOTAL_CONCEPTS %}
			<a href="skos.html" class="{% if thispage=="concepts" %}active{% endif %}">Concepts ({{TOTAL_CONCEPTS}})</a>
		{% endif %}
			
			
		

	</div>


	<div class="row">

		<!-- the graph -->
		
		<div class="col-md-12" id="the_graph">


		</div>


	</div>




{% endblock main_content %}



{% block extra_footer %}

	Visualization developed with <a class="greylink" href="https://github.com/d3/d3">d3.js</a>.
	
{% endblock extra_footer %}
	
	






{% block the_javascript %}





{# JAVASCRIPT #}

<script type="text/javascript" src="{{STATIC_URL}}libs/d3-v3/d3.min.js"></script>

<script type="text/javascript" src="{{STATIC_URL}}libs/jquery/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="{{STATIC_URL}}libs/jquery/jquery.slidereveal.min.js"></script>






{% include 'shared/js_slidereveal.html' %}





<script type="text/javascript">

    var root = {{JSON_DATA_OBJECTS|safe}} ;

	var w = window.innerWidth;
	var h = window.innerHeight;

	var w = 800;
	var h = 500;

	var x = d3.scale.linear().range([0, w]),
	    y = d3.scale.linear().range([0, h]);

	var vis = d3.select("#the_graph").append("div")
	    .attr("class", "chart")
	    .style("width", w + "px")
	    .style("height", h + "px")
	  .append("svg:svg")
	    .attr("width", w)
	    .attr("height", h);


    var tooltip = d3.select("body")
    .append("div")
    .style("position", "absolute")
    .style("border-radius", "5px")
    .style("z-index", "100")
    .style("visibility", "hidden")
    .style("opacity", ".85")
    .style("color", "lightsteelblue")
    .style("background", "white")
    .style("font-size", "40px")
    .text("a simple tooltip");


	var partition = d3.layout.partition()
	    .value(function(d) { return d.size; });

	// d3.json(JSON_FILE, function(root) {
	  var g = vis.selectAll("g")
	      .data(partition.nodes(root))
	    .enter().append("svg:g")
	      .attr("transform", function(d) { return "translate(" + x(d.y) + "," + y(d.x) + ")"; })
	      .on("click", click)
          .on("mouseover", function(d){
			d3.select(this).attr("fill", "white");
			tooltip.text(d.qname);
			tooltip.style("visibility", "visible"); })
          .on("mousemove", function(d){return tooltip.style("top",
		      (d3.event.pageY-100)+"px").style("left",(d3.event.pageX+50)+"px");})
          .on("mouseout", function(d){
                d3.select(this).attr("fill", ""); // default = no stroke
                return tooltip.style("visibility", "hidden");}
                );

	  var kx = w / root.dx,
	      ky = h / 1;

	  g.append("svg:rect")
	      .attr("width", root.dy * kx)
	      .attr("height", function(d) { return d.dx * ky; })
	      .attr("class", function(d) { return d.children ? "parent" : "child"; });

	  g.append("svg:text")
	      .attr("transform", transform)
	      .attr("dy", ".35em")
	      .style("opacity", function(d) { return d.dx * ky > 12 ? 1 : 0; })
	      .text(function(d) { return d.name; })


	  d3.select(window)
	      .on("click", function() { click(root); })

	  function click(d) {
	    if (!d.children) return;

	    kx = (d.y ? w - 40 : w) / (1 - d.y);
	    ky = h / d.dx;
	    x.domain([d.y, 1]).range([d.y ? 40 : 0, w]);
	    y.domain([d.x, d.x + d.dx]);

	    var t = g.transition()
	        .duration(d3.event.altKey ? 7500 : 750)
	        .attr("transform", function(d) { return "translate(" + x(d.y) + "," + y(d.x) + ")"; });

	    t.select("rect")
	        .attr("width", d.dy * kx)
	        .attr("height", function(d) { return d.dx * ky; });

	    t.select("text")
	        .attr("transform", transform)
	        .style("opacity", function(d) { return d.dx * ky > 12 ? 1 : 0; });

	    d3.event.stopPropagation();
	  }

	  function transform(d) {
	    return "translate(8," + d.dx * ky / 2 + ")";
	  }
	// });

    </script>





	

	{% endblock the_javascript %}




