From 50775bcb4ca05cc8985eebdeaea6f04da70465cc Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Thu, 22 May 2014 18:20:11 +0200 Subject: Highlight nodes with updated spam status --- js/spam.js | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'js') diff --git a/js/spam.js b/js/spam.js index 339f5be..0a99c80 100644 --- a/js/spam.js +++ b/js/spam.js @@ -398,20 +398,40 @@ function refreshSpam() { // update the spam levels in the dataset var nodes = force.nodes(); + var updated = []; nodes.forEach(function (node) { if (node.userid in map_userSpam) { - node.isSpam = map_userSpam[node.userid]; + // only mark as updated if there is actually a change + if (node.isSpam !== map_userSpam[node.userid]) { + node.isSpam = map_userSpam[node.userid]; + updated.push(node.userid); + } } else { console.log('New data is missing user', node.userid); } }); + console.log('Updated spam rating for', updated.length, 'nodes'); // change the appearance of displayed elements d3.select('#map').selectAll('.node') .data(nodes, function (d) { return d.userid; }) - .attr('class', getNodeClasses); + .filter(function (d) { + return updated.indexOf(d.userid) >= 0; + }) + .transition() + .duration(4000) + .attr('r', function (d) { + // make all nodes very visible + return Math.max(10, 4 * d.radius); + }) + .attr('class', getNodeClasses) + .transition() + .duration(1000) + .attr('r', function (d) { + return d.radius; + }); }); } -- cgit v1.2.1