lib/conceptql/behaviors/dottable.rb in conceptql-0.0.5 vs lib/conceptql/behaviors/dottable.rb in conceptql-0.0.6
- old
+ new
@@ -47,13 +47,22 @@
me[:shape] = shape if respond_to?(:shape)
me
end
end
- def link_to(g, dest_node)
+ def link_to(g, dest_node, db = nil)
+ edge_options = {}
+
types.each do |type|
- e = g.add_edges(graph_node(g), dest_node)
+ if db
+ my_n = my_n(db, type)
+ label = [' rows=' + my_count(db, type).to_s + ' ']
+ label << ' n=' + my_n.to_s + ' '
+ edge_options[:label] = label.join("\n")
+ edge_options[:style] = 'dashed' if my_n.zero?
+ end
+ e = g.add_edges(graph_node(g), dest_node, edge_options)
e[:color] = type_color(type)
end
end
def graph_it(g, db)
@@ -61,11 +70,19 @@
children.each do |child|
child.graph_it(g, db)
end
graph_node(g)
children.each do |child|
- child.link_to(g, graph_node(g))
+ child.link_to(g, graph_node(g), db)
end
+ end
+
+ def my_count(db, type)
+ evaluate(db).from_self.where(criterion_type: type.to_s).count
+ end
+
+ def my_n(db, type)
+ evaluate(db).from_self.where(criterion_type: type.to_s).select_group(:person_id).count
end
end
end
end