{% extends 'profiler/base.html' %}
{% block content %}
<label class="radio inline">Color by:</label>
<label class="radio inline">
  <input type="radio" name="colorBy" value="time" checked>
  Total Time
</label>
<label class="radio inline">
  <input type="radio" name="colorBy" value="count">
  Count
</label>
<label class="radio inline">
  <input type="radio" name="colorBy" value="average_time">
  Average Time
</label>

<div id="chart"></div>
<script type="text/javascript">
$(function(){
var data = toTree({{ stats|safe }},
function(row) { var p = (row['view']||'None').split('.'); p[p.length]=row['query']; return p;},
function(node, row) { 
    if (!!!node['time'])
        $.extend(node, row);
    else {
        if (node['normtime'] < row['normtime'])
            node['normtime'] = row['normtime'];
    }

});
data.x0=0;data.y0=0;

update(root = data, metrics = function(node){ 
			       if (node===data)
			       return ['Total time', 'Count', 'Average time'];
			       else
			       return [node.time, node.count, Math.round(node.average_time*100)/100];
});

});
</script>

{% endblock %}
