Commit 82b95c03 authored by Anze Vavpetic's avatar Anze Vavpetic

merge

parents dabcd4aa b2082f13
...@@ -10,9 +10,17 @@ def cforange_hierarchical_clustering(request,input_dict,output_dict,widget): ...@@ -10,9 +10,17 @@ def cforange_hierarchical_clustering(request,input_dict,output_dict,widget):
matrix = input_dict['dm'] matrix = input_dict['dm']
linkage = int(input_dict['linkage']) linkage = int(input_dict['linkage'])
root = Clustering.hierarchical_clustering(linkage, matrix) root = Clustering.hierarchical_clustering(linkage, matrix)
attributes = [x.name for x in matrix.items.domain] dm_examples = True
try:
attributes = [x.name for x in matrix.items.domain]
except:
attributes = ['attribute']
dm_examples = False
def build_hierarchy(node, root=False): def build_hierarchy(node, root=False):
values_dict = dict([(x,matrix.items[node.first][x].value) for x in attributes]) if not node.branches else {} if dm_examples:
values_dict = dict([(x,matrix.items[node.first][x].value) for x in attributes]) if not node.branches else {}
else:
values_dict = dict([(x,matrix.items[node.first].name) for x in attributes]) if not node.branches else {}
for attribute in values_dict.keys(): for attribute in values_dict.keys():
if type(values_dict[attribute]) == float: if type(values_dict[attribute]) == float:
values_dict[attribute]="%.3f" % values_dict[attribute] values_dict[attribute]="%.3f" % values_dict[attribute]
......
...@@ -164,14 +164,29 @@ if (vizualization=="circle") { ...@@ -164,14 +164,29 @@ if (vizualization=="circle") {
.attr("r", 3); .attr("r", 3);
} }
for (a in attributes) { $(".node").mouseenter(function() {
node.append("svg:text") alert("test");
.attr("dx", function(d) { return d.x < 180 ? 8 : -8; }) });
.attr("dy", ".31em")
.attr("text-anchor", function(d) { return d.x < 180 ? "start" : "end"; }) if (vizualization=="circle") {
.attr("transform", function(d) { return d.x < 180 ? null : "rotate(180)"; }) for (a in attributes) {
.attr("class", "attribute"+a+" attributes") node.append("svg:text")
.text(function(d) { return d.values[attributes[a]]; }); .attr("dx", function(d) { return d.x < 180 ? 8 : -8; })
.attr("dy", ".31em")
.attr("text-anchor", function(d) { return d.x < 180 ? "start" : "end"; })
.attr("transform", function(d) { return d.x < 180 ? null : "rotate(180)"; })
.attr("class", "attribute"+a+" attributes")
.text(function(d) { return d.values[attributes[a]]; });
}
} else {
for (a in attributes) {
node.append("svg:text")
.attr("dx", -10)
.attr("dy", 3)
.style("text-anchor", function(d) { return d.children ? "end" : "start"; })
.attr("class", "attribute"+a+" attributes")
.text(function(d) { return d.values[attributes[a]]; });
}
} }
$(".attributes").hide(); $(".attributes").hide();
......
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