Commit d0746d3a authored by Anze Vavpetic's avatar Anze Vavpetic

Merge branch 'dev' of workflow.ijs.si:mothra into dev

parents 1f9f7c1a afdcfb68
......@@ -17,7 +17,7 @@
}
</style>
<div id="widgetvisualization-{{widget.pk}}" rel="{{widget.pk}}" width="900" height="600" class="widgetvisualizationdialog" title="{{widget.name}}">
<div id="widgetvisualization-{{widget.pk}}" rel="{{widget.pk}}" width="900" height="750" class="widgetvisualizationdialog" title="{{widget.name}}">
......@@ -28,9 +28,9 @@
src="https://raw.github.com/mbostock/d3/master/d3.js"
var m = [20, 80, 20, 120],
var m = [20, 250, 20, 40],
w = 870 - m[1] - m[3],
h = 500 - m[0] - m[2],
h = 660 - m[0] - m[2],
i = 0,
json;
......@@ -64,11 +64,6 @@ function(json) {
// Initialize the display to show a few nodes.
json.children.forEach(toggleAll);
// toggle(json.children[1]);
//toggle(json.children[1].children[2]);
//toggle(json.children[9]);
//toggle(json.children[9].children[0]);
update(json);
// echo json;
......@@ -80,7 +75,7 @@ function update(source) {
var nodes = tree.nodes(json).reverse();
// Normalize for fixed-depth.
nodes.forEach(function(d) { d.y = d.depth * 100; });
// nodes.forEach(function(d) { d.y = d.depth * 100; });
// Update the nodes…
var node = vis.selectAll("g.node")
......@@ -97,9 +92,9 @@ function update(source) {
.style("fill", function(d) { return d._children ? "#F7B64C" : "#F2D5A8"; });
nodeEnter.append("svg:text")
.attr("x", function(d) { return d.children || d._children ? -10 : 10; })
.attr("x", function(d) { return d.children || d._children ? 10 : 10; })
.attr("dy", ".35em")
.attr("text-anchor", function(d) { return d.children || d._children ? "end" : "start"; })
.attr("text-anchor", "start")
.text(function(d) { return d.name; })
.style("fill-opacity", 1e-6);
......@@ -177,9 +172,6 @@ function toggle(d) {
}
}
</script>
{{json}}
</script>
</div>
\ No newline at end of file
......@@ -203,7 +203,8 @@ def treeToJSON(node, path="", nodes={}):
if path=="": #get the dictionary prepared, insert root node
nodes.update ({ #root node properties
"name":node.branch_selector.class_var.name,
"name": "root",
# "name":node.node_classifier.class_var.name,
"ID":node.reference(),
"children":[]
})
......@@ -214,7 +215,8 @@ def treeToJSON(node, path="", nodes={}):
try:
if node.branches[n].branch_selector: #if the node (branch) has branches
child = { #set node properties
"name":node.branch_descriptions[n] + " - " + node.branches[n].branch_selector.class_var.name,
"name":node.branch_selector.class_var.name[:15] + " "
+ node.branch_descriptions[n][:10],
"ID":node.branches[n].reference(),
"children":[] #stays open for future descendant nodes
}
......@@ -226,7 +228,13 @@ def treeToJSON(node, path="", nodes={}):
else: #if node is a leaf
child = {
"name":node.branch_descriptions[n] + " - " + node.branches[n].node_classifier.default_value.value,
"name":node.branch_selector.class_var.name + " "
+ node.branch_descriptions[n]
+ ": "
+ node.branches[n].node_classifier.default_value.value
+ " ("
+ str(node.branches[n].node_classifier.GetProbabilities*100)
+ "%)",
"ID":node.branches[n].reference(),
}
eval ("nodes" + path + ".append(" + str(child) + ")")
......@@ -246,7 +254,5 @@ def tree_visualization(request, input_dict, output_dict, widget):
tc = input_dict['clt']
jsonJ = treeToJSON(tc.tree)
print jsonJ
return render(request, 'visualizations/tree_visualization.html', {'widget':widget, 'input_dict':input_dict, 'json':jsonJ})
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment