From 56633d3b46a4e00a45a67cc9394b22208bf7a34a Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Wed, 21 May 2014 21:39:21 +0200 Subject: Rename group to userid to reflect actual data --- js/preprocess.js | 8 ++++---- js/spam.js | 14 +++++++------- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'js') diff --git a/js/preprocess.js b/js/preprocess.js index d65c7db..65d27c3 100644 --- a/js/preprocess.js +++ b/js/preprocess.js @@ -11,7 +11,7 @@ function filterEdges(data, ratelimit_max) { var users = {}; //data.nodes.length = 10000; data.nodes.forEach(function (user, i) { - users[user.group] = user; + users[user.userid] = user; }); var ratelimit_count = 0; @@ -70,12 +70,12 @@ function preprocess(data, options) { var hasRelated = {}; data.nodes = data.nodes.filter(function (d) { /* Uncomment if it seems to be useful. - if (!(d.group in hasRelations) && d.tweetCount >= 100) { + if (!(d.userid in hasRelations) && d.tweetCount >= 100) { console.log('Keeping lonely user with', d.tweetCount, 'tweets'); return true; } */ - return d.group in hasRelations; + return d.userid in hasRelations; }); console.log('Nodes count (after dropping loners):', data.nodes.length); } @@ -83,7 +83,7 @@ function preprocess(data, options) { // prepare data for force layout: map user IDs to indices var userIds_indices = {}; data.nodes.forEach(function (user, i) { - userIds_indices[user.group] = i; + userIds_indices[user.userid] = i; }); console.log('UserID to index map:', userIds_indices); diff --git a/js/spam.js b/js/spam.js index da3a99a..884d4f9 100644 --- a/js/spam.js +++ b/js/spam.js @@ -232,7 +232,7 @@ function processData(data) { .attr('target', '_blank') .attr('href', 'https://twitter.com/' + d.name) .text(d.name); - userInfo.select('.userid').text(d.group); + userInfo.select('.userid').text(d.userid); userInfo.select('.tweet-count') .text(d.tweetCount); userInfo.select('.spam-status') @@ -347,7 +347,7 @@ function requestUsersCsv(filename) { .row(function (d) { return { name: d.name, - group: +d.userid, + userid: +d.userid, tweetCount: d.tweetcount, radius: Math.sqrt(d.tweetcount), isSpam: +d.isspam, @@ -392,23 +392,23 @@ function refreshSpam() { // store spam levels for the new user var map_userSpam = {}; rows.forEach(function (user) { - map_userSpam[user.group] = user.isSpam; + map_userSpam[user.userid] = user.isSpam; }); // update the spam levels in the dataset var nodes = force.nodes(); nodes.forEach(function (node) { - if (node.group in map_userSpam) { - node.isSpam = map_userSpam[node.group]; + if (node.userid in map_userSpam) { + node.isSpam = map_userSpam[node.userid]; } else { - console.log('New data is missing user', node.group); + console.log('New data is missing user', node.userid); } }); // change the appearance of displayed elements d3.select('#map').selectAll('.node') .data(nodes, function (d) { - return d.group; + return d.userid; }) .attr('class', getNodeClasses); }); -- cgit v1.2.1