Published
Edited
May 30, 2019
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
USER_PREFIX = "N\0sourcecred\0github\0USERLIKE\0USER\0"
Insert cell
d3 = require("d3@5")
Insert cell
Insert cell
SC_10 = d3.json("https://gist.githubusercontent.com/decentralion/2e99e46eedd498f14445dbf71b3115c0/raw/7342bb9927d522064098e91eb4a029c3320cc9e7/sourcecred_sourcecred_0.1.json")
Insert cell
SC_20 = d3.json("https://gist.githubusercontent.com/decentralion/2e99e46eedd498f14445dbf71b3115c0/raw/7342bb9927d522064098e91eb4a029c3320cc9e7/sourcecred_sourcecred_0.2.json")
Insert cell
Insert cell
RESEARCH_05 = d3.json("https://gist.githubusercontent.com/decentralion/2e99e46eedd498f14445dbf71b3115c0/raw/58f2cf536480c29a2084d3c6a0fb071a1e9eff2a/sourcecred_research_0.05.json")
Insert cell
SC_05_LOWREPO = d3.json("https://gist.githubusercontent.com/decentralion/2e99e46eedd498f14445dbf71b3115c0/raw/6cbb205b93b3dc1afeafa460c75c808bf43c7cbe/sourcecred_sourcecred_0.05.lowrepo.json")
Insert cell
SC_PRG = d3.json("https://gist.githubusercontent.com/decentralion/2e99e46eedd498f14445dbf71b3115c0/raw/172fe9f5d72950541a574122a682fd65bb32e529/sourcecred_prg.json")
Insert cell
function prgToUserCred(json) {
const nodes = json[1].graphJSON[1].nodes;
const scores = json[1].scores;
const usersToIndex = new Map();
let totalUserScore = 0;
for (let i=0; i<nodes.length; i++) {
const node = nodes[i];
if (node[3] === "USER") {
const user = node[4];
usersToIndex.set(user, i);
totalUserScore += scores[i];
}
}
const scoreNormalizer = 1000 / totalUserScore;
const userToCred = {};
for (const [user, index] of usersToIndex.entries()) {
userToCred[user] = scores[index] * scoreNormalizer;
}
return userToCred;
}
Insert cell
baselineUserToCred = prgToUserCred(SC_PRG)
Insert cell
Insert cell
vl = require("@observablehq/vega-lite@0.1")
Insert cell
_ = require("lodash")
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more