diff options
| author | Alon Levy <alon@pobox.com> | 2014-12-08 00:12:20 +0200 |
|---|---|---|
| committer | Alon Levy <alon@pobox.com> | 2014-12-08 00:12:20 +0200 |
| commit | dfabcaf081cea2f7fce5c58c625a456d7689ebf2 (patch) | |
| tree | 528a5089b4528f9e49147812b0ab47a3d4576894 /src | |
| parent | 04266933f47ad46239ae3730bcf0fc7b6abf9926 (diff) | |
remove timeline code from rz_core; cleanup circle code
Diffstat (limited to 'src')
| -rw-r--r-- | src/rz_core.js | 133 |
1 files changed, 31 insertions, 102 deletions
diff --git a/src/rz_core.js b/src/rz_core.js index a05c7243..1e8507b1 100644 --- a/src/rz_core.js +++ b/src/rz_core.js @@ -5,7 +5,6 @@ function($, d3, consts, rz_bus, util, model_graph, model_core, view_helpers, vie var addednodes = [], vis, - graphstate = "GRAPH", graphinterval = 0, timeline_timer = 0, deliverables = [], @@ -188,12 +187,7 @@ var initDrawingArea = function () { function zoom() { zoomInProgress = true; - if (graphstate === "GRAPH") { - vis.attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")"); - } - if (graphstate === "TIMELINE") { - vis.attr("transform", "translate(0,0)scale(1)"); - } + vis.attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")"); d3.event.sourceEvent.stopPropagation(); } @@ -579,120 +573,55 @@ function tick(e) { var linktext = vis.selectAll(".linklabel").data(graph.links()); function transform(d) { - if (graphstate === "GRAPH" || d.type === "third-internship-proposal") { - if (check_for_nan(d.x) || check_for_nan(d.y)) { - return; - } - if (d.state === "temp") { - return "translate(" + d.x + "," + d.y + ")"; - } else { - return "translate(" + d.x + "," + d.y + ")"; - } - } else { - return "translate(0,0)"; + if (check_for_nan(d.x) || check_for_nan(d.y)) { + return; } return "translate(" + d.x + "," + d.y + ")"; } - if (graphstate === "TIMELINE") { - var k = 20 * e.alpha; - var today = new Date(); - var missingcounter = 0; - - graph.nodes().forEach(function(d, i) { - if ((d.start === 0 || d.end === 0)) { - d.x = 450 + missingcounter * 100; - d.y = window.innerWidth / 2; - if (missingcounter >= 6) { - d.x = 450 + (missingcounter - 6) * 100; - d.y = window.innerWidth / 2 + 50; - } - missingcounter++; + //circles animation + var tempcounter = 0, + temptotal = graph.nodes().filter(function(d){ + return d.state === "temp" && d.type !== "chainlink" && d.type !== "bubble"; + }).length; + if (temptotal !== newnodes) { + newnodes += temptotal / 15 / (newnodes * newnodes); + } + newnodes = Math.max(1, Math.min(newnodes, temptotal)); + graph.nodes().forEach(function(d, i) { + var r, a; + if (d.state === "temp") { + tempcounter++; + if (d.type==="chainlink" || d.type==="bubble") { + d.x = window.innerWidth / 2; + d.y = window.innerHeight / 2; } else { - //var min= 150+graphinterval*Math.ceil(Math.abs(d.start.getTime() - today.getTime()) / (1000 * 3600 * 24)) - $('.gantbox').scrollLeft(); - //var max= 150+graphinterval*Math.ceil(Math.abs(d.end.getTime() - d.start.getTime()) / (1000 * 3600 * 24)) - $('.gantbox').scrollLeft(); - //d.x = min+Math.sin(today.getTime()/1000*Math.PI*2/10)*max; - timeline_timer++; - if (timeline_timer < 3000) { - d.x = 150 + graphinterval * Math.ceil(Math.abs(d.start.getTime() - today.getTime()) / (1000 * 3600 * 24)) * timeline_timer / 3000; - d.y = 150 + d.start.getHours() * 17; - } else { - d.x = 150 + graphinterval * Math.ceil(Math.abs(d.start.getTime() - today.getTime()) / (1000 * 3600 * 24)); - d.y = 150 + d.start.getHours() * 17; - } - } - if (d.state === "chosen") { - scrollValue = d.x; - } - }); - } else { - //circles animation - var tempcounter = 0; - var temptotal = 0; - graph.nodes().forEach(function(d, i) { - if (d.state === "temp" && d.type!=="chainlink" && d.type!=="bubble") { - temptotal++; + r = 60 + newnodes * 20; + a = -Math.PI + Math.PI * 2 * (tempcounter-1) / newnodes + 0.3; + d.x = window.innerWidth / 2 + r * Math.cos(a); + d.y = window.innerHeight / 2 + r * Math.sin(a); } - }); - if(temptotal!==newnodes){ - newnodes+=temptotal/15/(newnodes*newnodes); - } - if(newnodes>=temptotal){ - newnodes=temptotal; + check_for_nan(d.x); + check_for_nan(d.y); } - if(newnodes<1)newnodes=1; - graph.nodes().forEach(function(d, i) { - if (d.state === "temp") { - tempcounter++; - if(d.type==="chainlink" || d.type==="bubble"){ - d.x = window.innerWidth / 2; - d.y = window.innerHeight / 2; - } else { - d.x = window.innerWidth / 2 + (60+newnodes*20) * Math.cos(-Math.PI+Math.PI * 2 * (tempcounter-1) / newnodes+0.3); - d.y = window.innerHeight / 2 + (60+newnodes*20) * Math.sin(-Math.PI+Math.PI * 2 * (tempcounter-1) / newnodes+0.3); - } - check_for_nan(d.x); - check_for_nan(d.y); - } - }); - } + }); link.attr("d", function(d, i) { var d_val, ghost; - if (graphstate === "GRAPH") { - var dx = d.__dst.x - d.__src.x, - dy = d.__dst.y - d.__src.y, - dr = Math.sqrt(dx * dx + dy * dy); - d_val = "M" + d.__src.x + "," + d.__src.y + "A" + dr + "," + dr + " 0 0,1 " + d.__dst.x + "," + d.__dst.y; - } else if (graphstate === "TIMELINE") { - if (d.state === "enter" || d.state === "exit") { - var dx = d.__dst.x - d.__src.x, - dy = d.__dst.y - d.__src.y, - dr = Math.sqrt(dx * dx + dy * dy) * 5; - d_val = "M" + d.__src.x + "," + d.__src.y + "A" + dr + "," + dr + " 0 0,1 " + d.__dst.x + "," + d.__dst.y; - } else { - var dx = d.__dst.x - d.__src.x, - dy = d.__dst.y - d.__src.y, - dr = Math.sqrt(dx * dx + dy * dy) * 5; - - d_val = "M" + 0 + "," + 0 + "A" + dr + "," + dr + " 0 0,1 " + 0 + "," + 0; - } - } + var dx = d.__dst.x - d.__src.x, + dy = d.__dst.y - d.__src.y, + dr = Math.sqrt(dx * dx + dy * dy); + d_val = "M" + d.__src.x + "," + d.__src.y + "A" + dr + "," + dr + " 0 0,1 " + d.__dst.x + "," + d.__dst.y; // update ghostlink position ghost = $(this.nextElementSibling); ghost.attr("d", d_val); return d_val; }); - linktext.attr("transform", function(d) { - if (graphstate === "GRAPH") { - return "translate(" + (d.__src.x + d.__dst.x) / 2 + "," + (d.__src.y + d.__dst.y) / 2 + ")"; - } else { - return "translate(0,0)"; - } + return "translate(" + (d.__src.x + d.__dst.x) / 2 + "," + (d.__src.y + d.__dst.y) / 2 + ")"; }); node.attr("transform", transform); |
