Skip to content
This repository
Browse code

Look for advertised data sources.

  • Loading branch information...
commit 918b85180adb5b9c24fc7db2194558f2572636a7 1 parent 94b07a1
Ward Cunningham authored
15 client/plugins/force/force.coffee
@@ -19,6 +19,16 @@ window.plugins.force =
19 19 """
20 20 w = 380
21 21 h = 230
  22 +
  23 + candidates = $(".item:lt(#{$('.item').index(div)})")
  24 + if (who = candidates.filter ".force-source:last").size()
  25 + data = who.get(0).forceData()
  26 + else
  27 + data = wiki.getData()
  28 +
  29 + json = $.extend true, {}, data
  30 + console.log json
  31 +
22 32 fill = d3.scale.category20()
23 33
24 34 vis = d3.select(div.get(0))
@@ -42,9 +52,6 @@ window.plugins.force =
42 52 .attr("d","M 0 0 L 10 5 L 0 10 z")
43 53 .attr("fill", "#BBBBBB");
44 54
45   - json = $.extend true, {}, wiki.getData()
46   - console.log json
47   -
48 55 force = d3.layout.force()
49 56 .charge(-120)
50 57 .linkDistance(30)
@@ -75,7 +82,7 @@ window.plugins.force =
75 82 .attr("r", 5)
76 83 .style("fill", (d) -> fill d.group)
77 84 .on("dblclick", (d) ->
78   - wiki.doInternalLink "#{d.name} Box", div.parents('.page'))
  85 + wiki.doInternalLink d.name, div.parents('.page'))
79 86 .call(force.drag)
80 87 node.append("svg:title").text((d, i) -> d.name)
81 88
14 client/plugins/force/force.js
@@ -7,15 +7,21 @@
7 7 return wiki.getScript('/js/d3/d3.js', function() {
8 8 return wiki.getScript('/js/d3/d3.geom.js', function() {
9 9 return wiki.getScript('/js/d3/d3.layout.js', function() {
10   - var fill, force, h, json, link, node, vis, w;
  10 + var candidates, data, fill, force, h, json, link, node, vis, w, who;
11 11 div.append("<style type=\"text/css\">\n circle.node {\n stroke: #fff;\n stroke-width: 1.5px;\n }\n\n line.link {\n stroke: #999;\n stroke-opacity: .6;\n }\n</style>");
12 12 w = 380;
13 13 h = 230;
  14 + candidates = $(".item:lt(" + ($('.item').index(div)) + ")");
  15 + if ((who = candidates.filter(".force-source:last")).size()) {
  16 + data = who.get(0).forceData();
  17 + } else {
  18 + data = wiki.getData();
  19 + }
  20 + json = $.extend(true, {}, data);
  21 + console.log(json);
14 22 fill = d3.scale.category20();
15 23 vis = d3.select(div.get(0)).append("svg:svg").attr("width", w).attr("height", h);
16 24 vis.append("svg:defs").selectAll("marker").data(["arrowhead"]).enter().append("svg:marker").attr("id", String).attr("viewBox", "0 0 10 10").attr("refX", "20").attr("refY", "5").attr("markerUnits", "strokeWidth").attr("markerWidth", "9").attr("markerHeight", "5").attr("orient", "auto").append("svg:path").attr("d", "M 0 0 L 10 5 L 0 10 z").attr("fill", "#BBBBBB");
17   - json = $.extend(true, {}, wiki.getData());
18   - console.log(json);
19 25 force = d3.layout.force().charge(-120).linkDistance(30).nodes(json.nodes).links(json.links).size([w, h]).start();
20 26 link = vis.selectAll("line.link").data(json.links).enter().append("svg:line").attr("class", "link").style("stroke-width", function(d) {
21 27 return Math.sqrt(d.value);
@@ -35,7 +41,7 @@
35 41 }).attr("r", 5).style("fill", function(d) {
36 42 return fill(d.group);
37 43 }).on("dblclick", function(d) {
38   - return wiki.doInternalLink("" + d.name + " Box", div.parents('.page'));
  44 + return wiki.doInternalLink(d.name, div.parents('.page'));
39 45 }).call(force.drag);
40 46 node.append("svg:title").text(function(d, i) {
41 47 return d.name;

0 comments on commit 918b851

Please sign in to comment.
Something went wrong with that request. Please try again.