Skip to content

Instantly share code, notes, and snippets.

@bluekvirus
Last active June 9, 2018 22:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bluekvirus/dd777b6fb084af9aca042249f40e9603 to your computer and use it in GitHub Desktop.
Save bluekvirus/dd777b6fb084af9aca042249f40e9603 to your computer and use it in GitHub Desktop.
ddn-discovery-demo
height: 800
// https://d3js.org/d3-force/ Version 1.1.0. Copyright 2018 Mike Bostock.
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-quadtree')) :
typeof define === 'function' && define.amd ? define(['exports', 'd3-quadtree'], factory) :
(factory((global.d3 = global.d3 || {}),global.d3));
}(this, (function (exports,d3Quadtree) { 'use strict';
var constant = function(x) {
return function() {
return x;
};
};
var jiggle = function() {
return (Math.random() - 0.5) * 1e-6;
};
function x(d) {
return d.x + d.vx;
}
function y(d) {
return d.y + d.vy;
}
var collide_selective = function(radius) {
var nodes,
radii,
strength = 1,
iterations = 1,
ignoredPairs = {},
radiiReduce = 0.75;
if (typeof radius !== "function") radius = constant(radius == null ? 1 : +radius);
function force() {
var i, n = nodes.length,
tree,
node,
xi,
yi,
ri,
ri2;
for (var k = 0; k < iterations; ++k) {
tree = d3Quadtree.quadtree(nodes, x, y).visitAfter(prepare);
for (i = 0; i < n; ++i) {
node = nodes[i];
ri = radii[node.index], ri2 = ri * ri;
xi = node.x + node.vx;
yi = node.y + node.vy;
tree.visit(apply);
}
}
function apply(quad, x0, y0, x1, y1) {
var data = quad.data, rj = quad.r, r = ri + rj;
if (data) {
if (data.index > node.index) {
var x = xi - data.x - data.vx,
y = yi - data.y - data.vy,
l = x * x + y * y;
// Utilizes the ignore dict and reduce the collision radius
if (ignoredPairs[data.index] && ignoredPairs[data.index].includes(node.index))
r = r * radiiReduce;
if (l < r * r) {
if (x === 0) x = jiggle(), l += x * x;
if (y === 0) y = jiggle(), l += y * y;
l = (r - (l = Math.sqrt(l))) / l * strength;
node.vx += (x *= l) * (r = (rj *= rj) / (ri2 + rj));
node.vy += (y *= l) * r;
data.vx -= x * (r = 1 - r);
data.vy -= y * r;
}
}
return;
}
return x0 > xi + r || x1 < xi - r || y0 > yi + r || y1 < yi - r;
}
}
function prepare(quad) {
if (quad.data) return quad.r = radii[quad.data.index];
for (var i = quad.r = 0; i < 4; ++i) {
if (quad[i] && quad[i].r > quad.r) {
quad.r = quad[i].r;
}
}
}
function initialize() {
if (!nodes) return;
var i, n = nodes.length, node;
radii = new Array(n);
for (i = 0; i < n; ++i) node = nodes[i], radii[node.index] = +radius(node, i, nodes);
}
force.initialize = function(_) {
nodes = _;
initialize();
};
force.iterations = function(_) {
return arguments.length ? (iterations = +_, force) : iterations;
};
force.strength = function(_) {
return arguments.length ? (strength = +_, force) : strength;
};
force.radius = function(_) {
return arguments.length ? (radius = typeof _ === "function" ? _ : constant(+_), initialize(), force) : radius;
};
// Added an ignore dict (array per node index)
force.ignore = function(_) {
return arguments.length ? (ignoredPairs = _, force) : ignoredPairs;
};
// Added a radii reduce percentage config var
force.radiusOfIgnored = function(_) {
return arguments.length ? (radiiReduce = _, force) : radiiReduce;
};
return force;
};
//export {default as forceCenter} from "./src/center";
//export {default as forceLink} from "./src/link";
//export {default as forceManyBody} from "./src/manyBody";
//export {default as forceRadial} from "./src/radial";
//export {default as forceSimulation} from "./src/simulation";
//export {default as forceX} from "./src/x";
//export {default as forceY} from "./src/y";
exports.forceCollideSelective = collide_selective;
Object.defineProperty(exports, '__esModule', { value: true });
})));
{
"nodes": [
{
"id": "9677ffDd-294A-CdB8-14A1-dFDADDa4AC1B",
"volume": 84,
"volume-unit": "GB",
"behaviors": [
"behavior Pfgfzwgm jhmdmg khouylyxxr pgangt.",
"behavior Smutjche ytsyqq navu sqvmyi.",
"behavior Rsnjhkew faopirfg kns uepjnat esixrpk lylrebhu.",
"behavior Yggq yxsdfbwo swfd qrh vjt oqihcdvm.",
"behavior Xpjbxot pejrq enysd wsosrrcih."
],
"locations": [
{
"longitude": -26.6,
"latitude": -46.154167619713
}
]
},
{
"id": "eBebbAE7-bCCD-E6D1-8D75-A8dB4Ae3a47D",
"volume": 66,
"volume-unit": "KB",
"behaviors": [
"behavior Kbdihtfoli nvsnr wqif xscko.",
"behavior Uswwpci pddb abhelqn oyxsgtho yshov.",
"behavior Olbkjb zynrhdd hbxkbjs obzvcmckx odyurl.",
"behavior Lqftoivx jmycmr ifnwnclsyw wiwg.",
"behavior Xfjemw ubck liurovvlt satymaa ssdwtxwq."
],
"locations": [
{
"longitude": -149.2,
"latitude": -65.54324733
},
{
"longitude": 7.910311880666,
"latitude": 46.812847388
},
{
"longitude": -47.510725314854525,
"latitude": -10.184236483557765
},
{
"longitude": -88.45468,
"latitude": 5.116762
},
{
"longitude": -81.46668695101107,
"latitude": -37
},
{
"longitude": 133.12856,
"latitude": -75.81487566531429
},
{
"longitude": 155.243447572117,
"latitude": 59.6401288579318
}
]
},
{
"id": "DCd5C8ED-133e-EdA8-66f3-A2c455b1c1d5",
"volume": 46,
"volume-unit": "MB",
"behaviors": [
"behavior Ctgxlkzhex rngv ngvcvughn eira.",
"behavior Xjnqti lfvetytwj rlb yggg tzrsee qqlicjt."
],
"locations": [
{
"longitude": -79,
"latitude": 39.5
}
]
},
{
"id": "bcA6A8b1-cDFC-FE01-F48b-DE5DAea5dFb0",
"volume": 5,
"volume-unit": "GB",
"behaviors": [
"behavior Hdc xwgsc rukhisqin fvufpnyfj.",
"behavior Eskd hhf gcugfxofr hhcxe.",
"behavior Llo tbfolh csxtpytghu xwsclt.",
"behavior Ekvofgrv dghgvzoe qcdfrbmw vkbynkhuiy tztu.",
"behavior Qiduavuhjb itmepo pkbqjv."
],
"locations": [
{
"longitude": -168.44274651635376,
"latitude": 6.6498
},
{
"longitude": 52.62741487,
"latitude": -22.67128545
},
{
"longitude": 65.2,
"latitude": -36.75
},
{
"longitude": -6.669791177797078,
"latitude": -7.374490593978
},
{
"longitude": -87.35787,
"latitude": -11.5625743
},
{
"longitude": 24.876224526434264,
"latitude": 36.93
},
{
"longitude": -40.48,
"latitude": -53.7902366874
},
{
"longitude": -111.53257367145,
"latitude": 26.163847
},
{
"longitude": -158,
"latitude": 8.6931
}
]
},
{
"id": "2F6b5c5e-FEC9-78C2-DED9-5EB89bcB23D8",
"volume": 85,
"volume-unit": "MB",
"behaviors": [
"behavior Ixykl feuwxsqn pqkgyj suekg.",
"behavior Ccid ndtnokbk ejtelwwilq ejsihdrb.",
"behavior Cgehsdl uladmcuvng yymmpeheo shhtuug."
],
"locations": [
{
"longitude": -92.53247988,
"latitude": 4.48
},
{
"longitude": 69.98778,
"latitude": 25.8
},
{
"longitude": 155.5970465778954,
"latitude": 68.625301
},
{
"longitude": 101.945363,
"latitude": -54.8
},
{
"longitude": 2.25,
"latitude": -78.84
},
{
"longitude": -12.2706712615292,
"latitude": -64.60060341551241
},
{
"longitude": 133.966153891882,
"latitude": 42.84
},
{
"longitude": -137.1831,
"latitude": -87.85100036
}
]
},
{
"id": "65e0E6A2-ceBA-EeDe-d8fd-eEfB5cBA5D4D",
"volume": 3,
"volume-unit": "TB",
"behaviors": [
"behavior Jlgah mylcjshv wfyfhmige.",
"behavior Jhax dgjg ygdqvjsyn xryq dvxfncshh."
],
"locations": [
{
"longitude": 118.7174893328731,
"latitude": 19.319
},
{
"longitude": -134.1506,
"latitude": 35.71634
},
{
"longitude": -30.658117957,
"latitude": 83.92484220341241
}
]
},
{
"id": "fECAB5b9-EFbB-3129-5bcE-fBeE8Df118Bf",
"volume": 15,
"volume-unit": "MB",
"behaviors": [
"behavior Czrlwcclx mxtyry kocnvhri girrsi rowgxku bmkosmir.",
"behavior Mreyqsbuq evjtkgb rnbxd msuqfemsoa qvingh.",
"behavior Altx fgbclsp lkj xyrdowo tmzvuhxgg.",
"behavior Jcxxwtxzpk oycxdor yznqxc snuvr.",
"behavior Pgfkpnzdfr hbghktydn mesyhpsv mjbedx eopef."
],
"locations": [
{
"longitude": 159.24938659839518,
"latitude": -69.52460357
},
{
"longitude": 114.34424487560499,
"latitude": -74.614279432
}
]
},
{
"id": "F52cffB3-1fD2-14bf-E557-ECAC24ebCB9E",
"volume": 42,
"volume-unit": "TB",
"behaviors": [
"behavior Eessmk annhxs qhbdhnrp rqdf.",
"behavior Magcsu cbmpliynw caji twrfvx.",
"behavior Smsjuns bhncudfgm bwkfqi bjbnon.",
"behavior Eqtlfigps qvjmn wgavifjzk bvqazgspf.",
"behavior Mpeirbxtg rdau vxrbgw woydib txpdvnk.",
"behavior Rwmellbp bnqpdxtzh jbpl pgwxa.",
"behavior Jvmu nmhprwtfoh ympteqxrky hhvoo."
],
"locations": [
{
"longitude": 116.812363337075,
"latitude": 30.0456
},
{
"longitude": 121.3520972638,
"latitude": 73.476834238597
},
{
"longitude": -122.33467124832,
"latitude": -69.356
},
{
"longitude": -85.878437787,
"latitude": -38.57197015
},
{
"longitude": -34.4217263477,
"latitude": 13.881347667288
},
{
"longitude": 14.24210655,
"latitude": 72.283646
},
{
"longitude": -82.72058,
"latitude": 65
},
{
"longitude": -96.3381,
"latitude": -67.563316
},
{
"longitude": 143.328,
"latitude": 49.08
}
]
},
{
"id": "cfdCf39A-58b4-C2aE-5dDE-7bADE457EC9E",
"volume": 45,
"volume-unit": "GB",
"behaviors": [
"behavior Bmitjumn iptm xniaiozrj sqbq tmusek.",
"behavior Xqlttij tmudz rler damkpb.",
"behavior Uixynheo ugbjspje kktcvrk stbm.",
"behavior Snpiaij vmoypj ueykj uzyy.",
"behavior Yxfupibhp fghyott gxkdlb wyg dgotgah mlpjwc."
],
"locations": [
{
"longitude": -162.7472168531747,
"latitude": 64.2337317
},
{
"longitude": 69.8,
"latitude": 74.73
},
{
"longitude": -143.3567159,
"latitude": 62.6585699717709
},
{
"longitude": 179.2123518,
"latitude": 22.2065628366947
},
{
"longitude": 118,
"latitude": 58.43305905888
},
{
"longitude": -31.38182653165913,
"latitude": 72.48
}
]
},
{
"id": "6Bd2D585-4e5e-c2C5-2BB7-BBdA7F1f8Cde",
"volume": 57,
"volume-unit": "B",
"behaviors": [
"behavior Dbcv wsnepoqely djzphwhe lgfzjgls.",
"behavior Tnryovsnz fbsdwdxq lhxpa iiju pdxfms.",
"behavior Nplazj arcnkcpoe pdozjezsgp ydssvwhlmq vmnxiom."
],
"locations": [
{
"longitude": -67.547132230364,
"latitude": 31.4633
},
{
"longitude": 102.3168488632434,
"latitude": 52.3
},
{
"longitude": 52.481527,
"latitude": -51.28176
},
{
"longitude": 138.34,
"latitude": -5.014499
},
{
"longitude": 17.0565781512,
"latitude": 61.3585773373176
},
{
"longitude": 107.315282632,
"latitude": -36.784966
},
{
"longitude": 170.83,
"latitude": 83.643077933896
},
{
"longitude": -62.1618731419381,
"latitude": -81.7596337025414
},
{
"longitude": -119,
"latitude": -14.617570958156533
},
{
"longitude": -114.82195553266,
"latitude": 80.5874134771158
}
]
},
{
"id": "7a825F79-77Ad-7D63-1dbf-7baEDDB3bb6d",
"volume": 31,
"volume-unit": "GB",
"behaviors": [
"behavior Wyasmyylp znyr lnlhqes jqtw sybuhhq elfvs.",
"behavior Zshlvpytxl ksnuha fjjm oehwkonhuw jwnqtro ymzjpunot.",
"behavior Uzmpnoye lga iivvlm uakwkapj ofxck.",
"behavior Jryi ehqsulvm yhyxlb noev llcinm.",
"behavior Jufm nzydg rwvhcdi.",
"behavior Byscpeif vwnfk rkxbtowq fia zms darxzjornw.",
"behavior Ihtgn ftxh jmfckr ogix mlko koingq."
],
"locations": [
{
"longitude": -158.489,
"latitude": -49.768
},
{
"longitude": -93.08247833892766,
"latitude": 27.52650161613
},
{
"longitude": -28.834577,
"latitude": 50.7279
},
{
"longitude": -81.5867321388405,
"latitude": 56.46192156263863
},
{
"longitude": -103.98528272227755,
"latitude": -51.6692757651359
}
]
},
{
"id": "C34beDbD-6e0e-ee67-f5e6-08B2E5ac3B2E",
"volume": 47,
"volume-unit": "GB",
"behaviors": [
"behavior Ictduk rbrkhum ibmf zpqanefca wxygon.",
"behavior Qhgbmsrg tagph qeeytxpis vpfwmcjx ymoqk.",
"behavior Tjfpy tyth bnpjui xsgvspu.",
"behavior Iwivz beshyr zytmbglub jhouq.",
"behavior Cjemxmr zwjfqky rvlcmeo mozztils rrukc.",
"behavior Lorxo xyueyyfw oggjrujck cyphxlg.",
"behavior Trehebv xglya zrqj."
],
"locations": [
{
"longitude": -6.7309894,
"latitude": 1.510144
},
{
"longitude": 47.773706,
"latitude": 18.53838382853
},
{
"longitude": -53.22347740667787,
"latitude": 59.933003427
},
{
"longitude": 84.552752862728,
"latitude": 64.271148
},
{
"longitude": 154.98586,
"latitude": -38.85144634957227
},
{
"longitude": -17.77,
"latitude": -57.6382733152
},
{
"longitude": -70.43248451484,
"latitude": 34.15016219516
}
]
},
{
"id": "3C52eC2A-C3cE-B76B-DE62-55810eF1366B",
"volume": 9,
"volume-unit": "KB",
"behaviors": [
"behavior Qenw ldxm vovamulp hvfckzhla.",
"behavior Aowwbe gqnt hwkqjrnll vut xoeqilpc.",
"behavior Lunfifk owglckx zsyiybrdid.",
"behavior Eomamjc sthosfh lulvt jcfj ugdd.",
"behavior Vigv dfawdfga pgonlgrp bgxwmmmm xsfuhski unrmtl.",
"behavior Ueftyygd vfarecvp pjficzn eelnhnkcf ejl nfawf.",
"behavior Pgqy tpukxvclc mdr vatbtveaz.",
"behavior Czle ffwgo bfsijw akjvb gxxd."
],
"locations": [
{
"longitude": 98.9871448444,
"latitude": -11.26
},
{
"longitude": -146.9537837836,
"latitude": -23.86349139
},
{
"longitude": 108.5290347261803,
"latitude": 44.772279163677446
},
{
"longitude": 169.6826617652294,
"latitude": -19.78
},
{
"longitude": -141.23545538354,
"latitude": -36.4854112271299
},
{
"longitude": -145.3585880118264,
"latitude": -63.1785655281673
}
]
},
{
"id": "A876A059-eBeB-B361-6EA4-Be19BF5Bfc84",
"volume": 55,
"volume-unit": "TB",
"behaviors": [
"behavior Ltg porkddgsx dawqnpbfdc.",
"behavior Goqz wxg btnvcuou nwrtd.",
"behavior Iskjc qewuhcy seynp ihjdpjrdux dfitx lhxdcp.",
"behavior Spyv ddtiu yjjgh rjbeogt tznwht srjdbhmcpg.",
"behavior Hyjkvmnebv ytfxxzxi yfsplsy hlqunob ysdadxg gxqsqqllv.",
"behavior Wiv dzbu egtr pswoelc rstbheh.",
"behavior Gxfkkkxlxc wtkea dlxazkk slhpn."
],
"locations": [
{
"longitude": 113.0072277,
"latitude": 16.38404175984569
},
{
"longitude": 147.23416274035276,
"latitude": 64.921
},
{
"longitude": -164.16899317,
"latitude": -40.54
},
{
"longitude": -99.8286,
"latitude": -46.235447380155776
},
{
"longitude": -139.413665655,
"latitude": 30.44441503029388
},
{
"longitude": 25.23228,
"latitude": -1.58773527316
},
{
"longitude": 81.175324,
"latitude": -62.0281135
},
{
"longitude": -25.7091,
"latitude": -19.38956254047
}
]
},
{
"id": "48bEfFCF-6D0B-2957-D3Ea-3f2D1Bb7ab6f",
"volume": 67,
"volume-unit": "GB",
"behaviors": [
"behavior Ajk qmhv dtnujmf.",
"behavior Mqiju ejzn ybp zvdcbhvgc ivrixg.",
"behavior Ycndkik jibglj vzzlstbsdm.",
"behavior Ntdpunjpn svkq wlvv lcsjobiv.",
"behavior Uwse kxcfkemkco usp xyg zjwlk.",
"behavior Sckjjxidkz ohczd ddx.",
"behavior Zhhfgvehh kxeg sxp pdbgeo."
],
"locations": [
{
"longitude": 93.783146122723,
"latitude": 16.2776659805
},
{
"longitude": 16.1870245,
"latitude": 0.263
},
{
"longitude": 31.749165838909,
"latitude": -53.88840209657384
},
{
"longitude": 34.3534521461,
"latitude": -73.2
},
{
"longitude": -32.4648,
"latitude": 26.513649948049427
},
{
"longitude": -103.6177180881684,
"latitude": 35.275
},
{
"longitude": 165.13738,
"latitude": -76.72984975
}
]
},
{
"id": "dF54af5C-eDEc-4cCd-E0A6-FF58A38C463d",
"volume": 95,
"volume-unit": "GB",
"behaviors": [
"behavior Byfy efnor eldb pal.",
"behavior Oiukwssn jgjde ylllowhd kreyay.",
"behavior Oxqmxrdk mhwpnz nutrpo mydqfzo jeykdhceog.",
"behavior Vgokmoivp opmida jnfkuozf.",
"behavior Fpqwiy bvjmg yqx jzdql.",
"behavior Sorc qngkkqo qyhc zoxenkrbi pltgtwfakd.",
"behavior Jrglbp ybxb vstpbw dfbzzmt.",
"behavior Qlijg oviochnrd mprtbf smbudlww."
],
"locations": [
{
"longitude": -12.94239168747671,
"latitude": 19
},
{
"longitude": 111.621133,
"latitude": 75.234283555
},
{
"longitude": 3.9595162,
"latitude": 89.18158665756
},
{
"longitude": 141.7315762933703,
"latitude": 50.325312
}
]
},
{
"id": "1Afff7DC-A981-B1D6-5597-6F43C16AAAAE",
"volume": 57,
"volume-unit": "KB",
"behaviors": [
"behavior Tssjrmv obsdrkjf bsmlhlyrsn jrzfpoo htjzgtcqmw.",
"behavior Whtsexmdr kvkcchhox unhh fetyj jkcecqdrc.",
"behavior Murg brkq huz ucvsg.",
"behavior Hefbfgbt ojndiwkylg tmteeivyd iorcnqgh tcwmxpki ihkyq.",
"behavior Rfbfqz eiqahjrmh kmewvvv imgmampd igdib.",
"behavior Cudjzqtmk nxbvxdngy mbenfiqqoq brttoe.",
"behavior Odmsorcwq urju fmraefdji bbcw.",
"behavior Ngahsagxio cblruyvnlh ilibcb yvorit aow rbv."
],
"locations": [
{
"longitude": -39.337366771,
"latitude": -13.365150121
},
{
"longitude": 5.79,
"latitude": -20.001
},
{
"longitude": 35.48852867,
"latitude": -35
},
{
"longitude": 128.69,
"latitude": -29.153643151635
},
{
"longitude": -175.93791455,
"latitude": -50.1241
},
{
"longitude": -81.66,
"latitude": 73.26631013
},
{
"longitude": -68.03721487258288,
"latitude": 27.46416164875266
}
]
},
{
"id": "fccFcca5-d867-16F1-3F6f-ed39F8ee8AbA",
"volume": 38,
"volume-unit": "MB",
"behaviors": [
"behavior Lcypjci mmjt cavebjsv pogk.",
"behavior Blkkjdmyx mkphwmgqc osddk ugozhmqu qeezxvhhvs.",
"behavior Qibm ggxsmjkvqm nhxwggn ggmpuulx.",
"behavior Qyht hicpgky bztov.",
"behavior Sklhb mdtvrujyu blphxyytl uwhjtrovkz rbbwlbfor mbotcicx.",
"behavior Qqnwb hfx wvm lkbmym.",
"behavior Dnfkdb kjjbgcn geooephdgq.",
"behavior Dgmp kylpqrflg vollre.",
"behavior Rwyfzg uonsskhs jrchxjjskp ztnekccwyc pumfxosqe."
],
"locations": [
{
"longitude": 145.3788754152,
"latitude": 43.130442965
},
{
"longitude": -66.88343226,
"latitude": -86.47651
},
{
"longitude": -60.986847204372,
"latitude": -63.29
},
{
"longitude": 160.0170431212954,
"latitude": 79.37275216644042
},
{
"longitude": -116.6611876,
"latitude": 45.86468856674524
},
{
"longitude": -79.3866688,
"latitude": 1.8163
}
]
},
{
"id": "ACCb92cE-C2ee-F7b6-e678-dAd6A3Ea2c6b",
"volume": 77,
"volume-unit": "MB",
"behaviors": [
"behavior Xqck hdv wlkw eqdferplt.",
"behavior Ivxeknr cxennwwo agjjodhp jwbzswuw.",
"behavior Fdrwhexcl tbgxnsvj dsuxkrw fqywwut.",
"behavior Qvzajucqt uldhshkel hzovtegs cprkry jhvh.",
"behavior Gppn hkunbrr ftqhzjkup.",
"behavior Xonlonfhio hatmt iqfuvv rldml.",
"behavior Joutqk dfsw ejxbxupryn.",
"behavior Uequpdr vttn wvif eogqhfnlr.",
"behavior Fpzbouw eukl sxjmc bbqurksgeo."
],
"locations": [
{
"longitude": -51.8512537602326,
"latitude": -83.01433598665392
},
{
"longitude": 91.6345799456,
"latitude": -1.3836610879
},
{
"longitude": 95.848120821143,
"latitude": 59.4445383893442
},
{
"longitude": -152.196481,
"latitude": -7.022
},
{
"longitude": 52.77469621628742,
"latitude": -57.81333468871594
},
{
"longitude": -159.99,
"latitude": -67.91397
},
{
"longitude": -119.51861753757737,
"latitude": -83.662751235
},
{
"longitude": 125.1616451177,
"latitude": -50.27063823228156
}
]
},
{
"id": "AD36c0b4-3dFB-29BF-D393-522C7ec27fd5",
"volume": 87,
"volume-unit": "MB",
"behaviors": [
"behavior Plrxlcsp nhvgaozah lnejwdqsbb hvnifyqct.",
"behavior Ogpc mpjbblrd htz hvchtetu nsfzjiq."
],
"locations": [
{
"longitude": 142.18,
"latitude": 76.898402
},
{
"longitude": 179.86401,
"latitude": 59.4737592579656
},
{
"longitude": 154.79,
"latitude": -16.134
},
{
"longitude": -95.2407,
"latitude": -62.3861134737488
},
{
"longitude": 20.722434784248183,
"latitude": -18.364825
},
{
"longitude": -103.485249,
"latitude": -50.86017858068325
},
{
"longitude": -3.488116333,
"latitude": -21.257369216030984
},
{
"longitude": 145.577,
"latitude": 89.481257472454
},
{
"longitude": 0.47855994184023,
"latitude": -64.6
},
{
"longitude": -8.25124,
"latitude": -76.628749515
}
]
},
{
"id": "c8C08b9f-8Ef8-e90E-0d6d-9885e2Dd208B",
"volume": 54,
"volume-unit": "KB",
"behaviors": [
"behavior Qmewrhxup nux psiro fhjg jjdmddy.",
"behavior Owo ide dgugvl xnugpmchc sfqvx pou.",
"behavior Yihuxkfo xejbiqvne qfn ftbpjzuv hmphzqbxmd kbcvspfio.",
"behavior Zuxcirqqsj moso vlyds xddotqit.",
"behavior Jfgyyobv yrvbkjprvc qjaqo lyiarc lcnr.",
"behavior Flhs ikjycv kfnoqen.",
"behavior Kwyooeway hqnycowd bftseozlz."
],
"locations": [
{
"longitude": -78.1957618631794,
"latitude": 2.6166574471547923
},
{
"longitude": 60.1421186371601,
"latitude": 41.877
},
{
"longitude": -67.86890461321266,
"latitude": 15.86738532477
}
]
},
{
"id": "cea59Fb0-c5d5-Ada5-C541-7fbCEBCD675b",
"volume": 18,
"volume-unit": "B",
"behaviors": [
"behavior Nfeykbbk dnyqif iuiq eqorxdhtsf.",
"behavior Gypmpojj qgzw nfhlqg pcrpxkeo kgogpj tvydwbwq.",
"behavior Hmbczbt vxrts oqudxsnhq slqekca.",
"behavior Lrrtcge pdrguey weh.",
"behavior Ghia jfujzc zswe uvtcx nvkfgewkj bxmgqrl.",
"behavior Kpiisjcj clsgsk srjo."
],
"locations": [
{
"longitude": -155,
"latitude": 19.1712880637
},
{
"longitude": 115.115179792,
"latitude": -13.8
},
{
"longitude": 13.262494447753,
"latitude": 13.93658289616313
},
{
"longitude": 105.561473557593,
"latitude": -31.2816
},
{
"longitude": 3.062424423762,
"latitude": 51.1123
},
{
"longitude": -176.170706850346,
"latitude": 42.79052643
},
{
"longitude": -76.3,
"latitude": -83.27291717822152
},
{
"longitude": 134.31488,
"latitude": -88.424582770322
},
{
"longitude": 4.5647518145,
"latitude": -39.7710429
},
{
"longitude": 89,
"latitude": 10.4457862
}
]
},
{
"id": "858FdCE3-a4c5-6b27-D4Ba-A8CDDBaf8f5D",
"volume": 47,
"volume-unit": "MB",
"behaviors": [
"behavior Goq glw epolxpcrb itiknjomf.",
"behavior Xdftfpcn ovpcn pshp bbqb qrjxcphs.",
"behavior Vxycjsoc nhyhbheta wxegx vjxr.",
"behavior Knclg chab ytorbceb gede.",
"behavior Ucfokgz vocodpdu nsmqovivv oqdjglj jqvcyvr."
],
"locations": [
{
"longitude": 4.35342687,
"latitude": -45.26941775
},
{
"longitude": 32.55,
"latitude": 66.662338883236
},
{
"longitude": -17.1288,
"latitude": -76.96463231668925
},
{
"longitude": 14.7,
"latitude": -82.2735
},
{
"longitude": -94.25629,
"latitude": -12.216721461482745
},
{
"longitude": -4.82619108873298,
"latitude": 17.486642862
},
{
"longitude": -148.88842,
"latitude": -26.214735486035828
},
{
"longitude": 176.17533917,
"latitude": -76.31811988148148
},
{
"longitude": 37.3,
"latitude": 80.6982836423425
}
]
},
{
"id": "BCa9F1Fd-d47e-01dC-C33f-Ece2b91C628e",
"volume": 100,
"volume-unit": "KB",
"behaviors": [
"behavior Lalfai qzrauneve weemje.",
"behavior Cgoa vkzgrsnq nousuhmj dbuvv.",
"behavior Seois dbtaqwyu pko poqskuwb fqgejvn.",
"behavior Ksch xvpd txyfi.",
"behavior Birvp yoshht gmcbkuvyb vryf yuqqx.",
"behavior Ksjfw fthdywch tkutsfku yfackoitds gdvdxhwk eomqvzvhrc."
],
"locations": [
{
"longitude": 45,
"latitude": -68.97244
},
{
"longitude": 8.07,
"latitude": 73.7924538
},
{
"longitude": 77.3204783746,
"latitude": -14.74771782154918
},
{
"longitude": -158.84995172,
"latitude": -30.24793335312
},
{
"longitude": -148.24715533,
"latitude": -69.39246
},
{
"longitude": 88.9433391634767,
"latitude": -85.6
},
{
"longitude": 6.03503385889325,
"latitude": 32.66484393577183
},
{
"longitude": -154.9,
"latitude": 16.581054055932
},
{
"longitude": 35.01572241,
"latitude": -59.1985915
}
]
},
{
"id": "CE5AcFab-564F-Fe99-4a5d-D8ade67FEc9B",
"volume": 58,
"volume-unit": "MB",
"behaviors": [
"behavior Ffwefpu gqqajmo xnwrri xkfnkiery zls.",
"behavior Wbffrvxtl kkext fvijqksrh hff.",
"behavior Eiuug fqrtljpjju onnzlgk trfhth tlhbsrqme.",
"behavior Cmol rawyipyd fhsylbzgzk zpat yfjwhtxr.",
"behavior Yxawkmd ommdo tuhrgfb mbbbqklqk fqk.",
"behavior Eijskjyp kklcftkly beequbwp anbbuqybx.",
"behavior Dtxfitx ber xwf.",
"behavior Cxmyniz ygofgbdc ovkfvfflfx."
],
"locations": [
{
"longitude": -130.9866,
"latitude": 8.697263186169884
},
{
"longitude": -8.05785497311863,
"latitude": -58.1572
},
{
"longitude": -80.77972363331341,
"latitude": -25.335914138596934
},
{
"longitude": 138.5391025314578,
"latitude": 42.07180752651357
},
{
"longitude": 143.722641682,
"latitude": -16.623135723483003
},
{
"longitude": 144.3,
"latitude": -17.9268071086886
},
{
"longitude": 120.8865657,
"latitude": 64.21519756312486
},
{
"longitude": 31.239519467,
"latitude": 76.7
}
]
}
],
"overlappings": [
{
"nodes": [
5,
14
],
"shared_behaviors": [
"behavior Tarrei tibv tfkyiq.",
"behavior Bcejgy uhdpbp hhjwvfs oiowktju ujw.",
"behavior Jljiixah wcds boctfp nibj cylrmo.",
"behavior Vvulxyjax scsgglqll ecuzcmnh."
]
},
{
"nodes": [
9,
19
],
"shared_behaviors": [
"behavior Gngudhhg hsx mytjlhep itwmnd fhjlpthmv smcus.",
"behavior Jidf abjgifrl bjhtog.",
"behavior Kpbx mnwsyples fob eglixn cgqo.",
"behavior Sucn tbroa rpryt xdyhq ropgeuamd unjfcxfra."
]
},
{
"nodes": [
8,
17
],
"shared_behaviors": [
"behavior Dcj iupoyf rodt gbrx ziwwqet.",
"behavior Ijeypjb mgblsjna opzfjjeln ywopl mmksbs yopbxxubu.",
"behavior Rfljqx lmhqcg ccqdxe xtynrosbt."
]
},
{
"nodes": [
10,
24
],
"shared_behaviors": [
"behavior Lngvo ctxu ejf jjbkxnciyp rknsghhlgw.",
"behavior Lyumkpjkl afm nsmwjy.",
"behavior Cocfidxfw rsjlyl kotsnuhk.",
"behavior Ptoeokazm kxscnl ycyuijvrw cbppcs oobit.",
"behavior Bqhpqek olvnef eqn ywidne."
]
},
{
"nodes": [
2,
13
],
"shared_behaviors": [
"behavior Trydjbf ullp yojqpkhe mtuqak cyqqnvvqw cnoqpwat.",
"behavior Pbbundmcpg xevhnyvvo cmrtflobt wfjvndhysw saohncd.",
"behavior Tpvgf dglpmwxhpt dssfzs."
]
},
{
"nodes": [
10,
22
],
"shared_behaviors": [
"behavior Ywrkfrehb ufay temutwlxry.",
"behavior Ghfvkc cbeta syemdrp.",
"behavior Inqvyqzk aytnu nftwk hmul bmyw tjiwnviw.",
"behavior Cdvvmd qmobuh ohxa ommkpy vilhyvjct."
]
},
{
"nodes": [
10,
23
],
"shared_behaviors": [
"behavior Jxgge mfkdcw dkmopol weweq.",
"behavior Grw rcclcebrow jbbptlwj xlya wjrldcicu."
]
},
{
"nodes": [
0,
12
],
"shared_behaviors": [
"behavior Qoqy xhiaiv rugfluk emwrf gbxsu.",
"behavior Ofhlqmis lzhhqxk gml qemqrwhei ofctxrljj.",
"behavior Vbqf jywdizlbje brwho iilp.",
"behavior Mrrmxbq apf kfghos mfkuhcfru foopj.",
"behavior Xzxdn wdsqrhcei nyldvn vninjipa xhtcvxy."
]
}
],
"connections": [
{
"nodes": [
2,
0
],
"volumes": [
{
"direction": "l2r",
"size": 51,
"unit": "GB"
},
{
"direction": "r2l",
"size": 64,
"unit": "MB"
}
],
"apps": [
"nntp",
"mailto",
"prospero",
"mid",
"http"
],
"users": [
"timothy",
"laura",
"ronald",
"eric",
"william",
"jennifer",
"sarah",
"george"
]
},
{
"nodes": [
19,
7
],
"volumes": [
{
"direction": "l2r",
"size": 66,
"unit": "B"
},
{
"direction": "r2l",
"size": 90,
"unit": "MB"
}
],
"apps": [
"mailto",
"rlogin",
"tn3270",
"nntp",
"telnet"
],
"users": [
"matthew",
"melissa"
]
},
{
"nodes": [
14,
6
],
"volumes": [
{
"direction": "l2r",
"size": 88,
"unit": "MB"
},
{
"direction": "r2l",
"size": 30,
"unit": "MB"
}
],
"apps": [
"gopher",
"mid",
"gopher"
],
"users": [
"michael",
"angela",
"michael",
"karen",
"frank"
]
},
{
"nodes": [
24,
4
],
"volumes": [
{
"direction": "l2r",
"size": 4,
"unit": "GB"
},
{
"direction": "r2l",
"size": 41,
"unit": "KB"
}
],
"apps": [
"telnet",
"telnet",
"telnet",
"news",
"telnet"
],
"users": [
"donald",
"charles",
"cynthia",
"margaret",
"elizabeth",
"donald",
"gary",
"larry",
"steven"
]
},
{
"nodes": [
1,
9
],
"volumes": [
{
"direction": "l2r",
"size": 48,
"unit": "MB"
},
{
"direction": "r2l",
"size": 57,
"unit": "KB"
}
],
"apps": [
"news",
"tn3270",
"telnet"
],
"users": [
"joseph",
"shirley",
"linda",
"matthew",
"michelle",
"frank",
"margaret",
"sharon",
"brian"
]
},
{
"nodes": [
10,
16
],
"volumes": [
{
"direction": "l2r",
"size": 39,
"unit": "GB"
},
{
"direction": "r2l",
"size": 20,
"unit": "GB"
}
],
"apps": [
"nntp",
"telnet",
"gopher",
"mailto",
"prospero"
],
"users": [
"margaret",
"joseph",
"linda"
]
}
]
}
/**
* Drawing the DDN circles with overlapping to indicate #of shared behaviors.
*
* Overlapping impl
* ----------------
* a. Custom selective Collide Force (*Yes, currently in use)
* b. Custom negative Link Force (?Considering, not yet in use)
*
* @author Tim Lauv
* @created 2018.06.08
*/
document.addEventListener('DOMContentLoaded', function(){
console.log('READY!');
// Globals
var volumeScale = {
'B': 1,
'KB': 1.024,
'MB': 1.024 * 1.024,
'GB': 1.024 * 1.024 * 1.024,
'TB': 1.024 * 1.024 * 1.024 * 1.024,
}
// Hooks up the <SVG> canvas in index.html
var svg = d3.select('svg'),
width = svg.attr('width'),
height = svg.attr('height');
// D3 Forces (simulation)
var sim = d3.forceSimulation()
.force('center', d3.forceCenter(width / 2, height / 2))
.force('overlap', d3.forceLink().id(d => d.index).strength(0.5))
.force('collide', d3.forceCollideSelective().radius(d => d.volume * volumeScale[d['volume-unit']] / 1.5 + 4).strength(0.1))
//.force('charge', d3.forceManyBody().strength(10));
// Raw data in JSON format
d3.json('ddn-discovery-data-sample.json').then(data => {
var extracted = {
nodes: [],
links: [],
};
// Note: extract nodes/edges and calculate connected group index for coloring (sort by source index)
extracted.nodes = data.nodes;
extracted.links = data.overlappings.map(edge => {
return {source: edge.nodes[0], target: edge.nodes[1], sortIndex: edge.nodes[0] + 1};
}).sort(function(a, b){
return a.sortIndex - b.sortIndex;
});
var ignoredPairs = {}
extracted.links.forEach(edge => {
extracted.nodes[edge.source].groupIndex = extracted.nodes[edge.source].groupIndex || edge.sortIndex;
extracted.nodes[edge.target].groupIndex = extracted.nodes[edge.source].groupIndex;
var ignoredPair = ignoredPairs[edge.source] || [];
ignoredPair.push(edge.target);
ignoredPairs[edge.source] = ignoredPair;
ignoredPair = ignoredPairs[edge.target] || [];
ignoredPair.push(edge.source);
ignoredPairs[edge.target] = ignoredPair;
});
sim.force('collide').ignore(ignoredPairs);
// Graphics Rendering (create svg elements to represent extracted.nodes/links)
var g_link = svg.append('g').attr('class', 'links').selectAll('line').data(extracted.links).enter()
.append('line');
var g_node = svg.append('g').attr('class', 'nodes').selectAll('circle').data(extracted.nodes).enter()
.append('circle')
.attr('r', d => d.volume * volumeScale[d['volume-unit']] / 1.5)
.attr('fill', d => !d.groupIndex ? '#FFFFFF' : d3.interpolateCool(d.groupIndex / extracted.nodes.length));
// Patch extracted.nodes/links data with force adjusted position values
sim.nodes(extracted.nodes)
// Upon position changes (per ticking) update svg elements accordingly
.on('tick', function(){
// Note: .x, .y is now adjusted by the forces!
g_node.attr('cx', d => d.x)
.attr('cy', d => d.y);
g_link.attr('x1', d => d.source.x)
.attr('y1', d => d.source.y)
.attr('x2', d => d.target.x)
.attr('y2', d => d.target.y);
}).force('overlap').links(extracted.links);
// Note: must add nodes before links! since link refers to nodes!!
});
});
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.nodes circle {
/*fill: none;*/
fill-opacity: 0.4;
stroke: #000000;
stroke-width: 3px;
}
.links line {
stroke: #dddddd;
stroke-width: 2px;
}
</style>
<svg width="960" height="800"></svg>
<script src="https://d3js.org/d3.v5.min.js"></script>
<script src="d3-force-custom.js"></script>
<script src="draw.js"></script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment