From 793ca4d46f78243a57bc17ab0575877093a851bf Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Sun, 28 Sep 2014 21:24:50 +0300 Subject: rhizicore/update: use object for slight readability win/lose (line win) --- scripts/rhizicore.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'scripts') diff --git a/scripts/rhizicore.js b/scripts/rhizicore.js index c64621d2..2a734bc5 100644 --- a/scripts/rhizicore.js +++ b/scripts/rhizicore.js @@ -488,8 +488,12 @@ function myGraph(el) { nodes = force.nodes(); links = force.links(); - var update = function() { + var state_to_link_class = { + enter:'enterlink graph', + exit:'exitlink graph', + }; + var update = function() { vis.selectAll(".graph").remove(); link = vis.selectAll(".link") @@ -521,13 +525,7 @@ function myGraph(el) { link.enter().append("path") .attr("d", "M0,-5L10,0L0,5") .attr("class", function(d) { - - if (d.state === "enter") { - return "enterlink graph"; - } else if (d.state === "exit") { - return "exitlink graph"; - } else return "link graph"; - + return state_to_link_class[d.state] || 'link graph'; }) .style("stroke-dasharray", function(d,i){ if(d.name && d.name.replace(/ /g,"")=="and" && d.state==="temp") -- cgit v1.3.1