Created
May 8, 2019 11:05
-
-
Save aborruso/f5f2375c07479ae2327bb1d384b73f73 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<script src="https://platform.twitter.com/widgets.js"></script> | |
<script src="https://d3js.org/d3.v4.min.js"></script> | |
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script> | |
<style> | |
.links line { | |
stroke: #999; | |
stroke-opacity: 0.8; | |
stroke-width: 2px; | |
} | |
line.reply { | |
stroke: #999; | |
} | |
line.retweet { | |
stroke-dasharray: 5; | |
} | |
line.quote { | |
stroke-dasharray: 5; | |
} | |
.nodes circle { | |
stroke: red; | |
fill: red; | |
stroke-width: 1.5px; | |
} | |
circle.retweet { | |
fill: white; | |
stroke: #999; | |
} | |
circle.reply { | |
fill: #999; | |
stroke: #999; | |
} | |
circle.quote { | |
fill: yellow; | |
stroke: yellow; | |
} | |
#graph { | |
width: 99vw; | |
height: 99vh; | |
} | |
#tweet { | |
position: absolute; | |
left: 100px; | |
top: 150px; | |
} | |
</style> | |
<svg id="graph"></svg> | |
<div id="tweet"></div> | |
<script> | |
var width = $(window).width(); | |
var height = $(window).height(); | |
var svg = d3.select("svg") | |
.attr("height", height) | |
.attr("width", width); | |
var color = d3.scaleOrdinal(d3.schemeCategory20c); | |
var simulation = d3.forceSimulation() | |
.velocityDecay(0.6) | |
.force("link", d3.forceLink().id(function(d) { return d.id; })) | |
.force("charge", d3.forceManyBody()) | |
.force("center", d3.forceCenter(width / 2, height / 2)); | |
var graph = { | |
"nodes": [ | |
{ | |
"id": "1126001087792676864", | |
"type": "reply", | |
"screen_name": "Fabiazep" | |
}, | |
{ | |
"id": "1125396760271179777", | |
"type": null, | |
"screen_name": "matt_fortini" | |
}, | |
{ | |
"id": "1126004676598620160", | |
"type": "reply", | |
"screen_name": "matt_fortini" | |
}, | |
{ | |
"id": "1125823561996877826", | |
"type": "reply", | |
"screen_name": "simonealiprandi" | |
}, | |
{ | |
"id": "1125838865732919297", | |
"type": "reply", | |
"screen_name": "matt_fortini" | |
}, | |
{ | |
"id": "1125840097587486720", | |
"type": "reply", | |
"screen_name": "simonealiprandi" | |
}, | |
{ | |
"id": "1125989399538302976", | |
"type": "reply", | |
"screen_name": "morenaragone" | |
}, | |
{ | |
"id": "1126002925732601856", | |
"type": "reply", | |
"screen_name": "MonicaPalmirani" | |
}, | |
{ | |
"id": "1126003651099725824", | |
"type": "reply", | |
"screen_name": "morenaragone" | |
}, | |
{ | |
"id": "1126015362670235648", | |
"type": "reply", | |
"screen_name": "GiorgiaLodi" | |
}, | |
{ | |
"id": "1126018061734174722", | |
"type": "reply", | |
"screen_name": "matt_fortini" | |
}, | |
{ | |
"id": "1126028000464601088", | |
"type": "reply", | |
"screen_name": "GiorgiaLodi" | |
}, | |
{ | |
"id": "1126019268221513733", | |
"type": "reply", | |
"screen_name": "morenaragone" | |
}, | |
{ | |
"id": "1126029042833137665", | |
"type": "reply", | |
"screen_name": "GiorgiaLodi" | |
}, | |
{ | |
"id": "1126020349592776705", | |
"type": "reply", | |
"screen_name": "matt_fortini" | |
}, | |
{ | |
"id": "1126020884928577537", | |
"type": "reply", | |
"screen_name": "cirospat" | |
}, | |
{ | |
"id": "1126028949757341696", | |
"type": "reply", | |
"screen_name": "GiorgiaLodi" | |
}, | |
{ | |
"id": "1126029698079842304", | |
"type": "reply", | |
"screen_name": "morenaragone" | |
}, | |
{ | |
"id": "1126045236508221441", | |
"type": "reply", | |
"screen_name": "cirospat" | |
}, | |
{ | |
"id": "1126029903000948736", | |
"type": "reply", | |
"screen_name": "GiorgiaLodi" | |
}, | |
{ | |
"id": "1126021309664780288", | |
"type": "reply", | |
"screen_name": "morenaragone" | |
}, | |
{ | |
"id": "1126020630938304512", | |
"type": "reply", | |
"screen_name": "morenaragone" | |
}, | |
{ | |
"id": "1126032258161418240", | |
"type": "reply", | |
"screen_name": "MonicaPalmirani" | |
}, | |
{ | |
"id": "1126032572180463616", | |
"type": "reply", | |
"screen_name": "morenaragone" | |
}, | |
{ | |
"id": "1126021579031363584", | |
"type": "reply", | |
"screen_name": "aborruso" | |
}, | |
{ | |
"id": "1125841043889455104", | |
"type": "reply", | |
"screen_name": "simonealiprandi" | |
}, | |
{ | |
"id": "1125996706171105280", | |
"type": "reply", | |
"screen_name": "matt_fortini" | |
}, | |
{ | |
"id": "1126008771879276544", | |
"type": "reply", | |
"screen_name": "AndreaDEramo70" | |
}, | |
{ | |
"id": "1126010426435809280", | |
"type": "reply", | |
"screen_name": "matt_fortini" | |
}, | |
{ | |
"id": "1126018936783429632", | |
"type": "reply", | |
"screen_name": "AndreaDEramo70" | |
}, | |
{ | |
"id": "1126021080932585472", | |
"type": "reply", | |
"screen_name": "matt_fortini" | |
}, | |
{ | |
"id": "1126020255724208128", | |
"type": "reply", | |
"screen_name": "morenaragone" | |
}, | |
{ | |
"id": "1126035265565409280", | |
"type": "reply", | |
"screen_name": "AndreaDEramo70" | |
}, | |
{ | |
"id": "1126044388138913793", | |
"type": "reply", | |
"screen_name": "matt_fortini" | |
}, | |
{ | |
"id": "1126060071002279936", | |
"type": "reply", | |
"screen_name": "vincpatruno" | |
}, | |
{ | |
"id": "1126063424755122176", | |
"type": "reply", | |
"screen_name": "matt_fortini" | |
}, | |
{ | |
"id": "1126065438784479232", | |
"type": "reply", | |
"screen_name": "vincpatruno" | |
}, | |
{ | |
"id": "1126066008320561152", | |
"type": "reply", | |
"screen_name": "GiorgiaLodi" | |
}, | |
{ | |
"id": "1126067335213797377", | |
"type": "reply", | |
"screen_name": "morenaragone" | |
}, | |
{ | |
"id": "1126067612792840194", | |
"type": "reply", | |
"screen_name": "GiorgiaLodi" | |
}, | |
{ | |
"id": "1126060636302188544", | |
"type": "reply", | |
"screen_name": "matt_fortini" | |
}, | |
{ | |
"id": "1126062713216675841", | |
"type": "reply", | |
"screen_name": "vincpatruno" | |
}, | |
{ | |
"id": "1126064120015523840", | |
"type": "reply", | |
"screen_name": "aborruso" | |
}, | |
{ | |
"id": "1126066352836546560", | |
"type": "reply", | |
"screen_name": "matt_fortini" | |
}, | |
{ | |
"id": "1126068658395021312", | |
"type": "reply", | |
"screen_name": "GiorgiaLodi" | |
}, | |
{ | |
"id": "1126069072930770944", | |
"type": "reply", | |
"screen_name": "morenaragone" | |
}, | |
{ | |
"id": "1126068126070788096", | |
"type": "reply", | |
"screen_name": "morenaragone" | |
}, | |
{ | |
"id": "1126064591002329088", | |
"type": "reply", | |
"screen_name": "MonicaPalmirani" | |
}, | |
{ | |
"id": "1126066481886842880", | |
"type": "reply", | |
"screen_name": "aborruso" | |
}, | |
{ | |
"id": "1126068589717532672", | |
"type": "reply", | |
"screen_name": "morenaragone" | |
}, | |
{ | |
"id": "1126044078297288704", | |
"type": "reply", | |
"screen_name": "matt_fortini" | |
}, | |
{ | |
"id": "1126064948470218753", | |
"type": "reply", | |
"screen_name": "GiorgiaLodi" | |
}, | |
{ | |
"id": "1126065235436146688", | |
"type": "reply", | |
"screen_name": "matt_fortini" | |
}, | |
{ | |
"id": "1126066330908729345", | |
"type": "reply", | |
"screen_name": "GiorgiaLodi" | |
}, | |
{ | |
"id": "1126045073039400960", | |
"type": "reply", | |
"screen_name": "MonicaPalmirani" | |
}, | |
{ | |
"id": "1126064757646200832", | |
"type": "reply", | |
"screen_name": "eliogullo" | |
}, | |
{ | |
"id": "1126065540945125376", | |
"type": "reply", | |
"screen_name": "GiorgiaLodi" | |
}, | |
{ | |
"id": "1126045280267395072", | |
"type": "reply", | |
"screen_name": "morenaragone" | |
}, | |
{ | |
"id": "1125843384793477120", | |
"type": "reply", | |
"screen_name": "GiorgiaLodi" | |
}, | |
{ | |
"id": "1125879581305712640", | |
"type": "reply", | |
"screen_name": "matt_fortini" | |
}, | |
{ | |
"id": "1126014987862978560", | |
"type": "reply", | |
"screen_name": "GiorgiaLodi" | |
}, | |
{ | |
"id": "1125846267047940096", | |
"type": "reply", | |
"screen_name": "simonealiprandi" | |
}, | |
{ | |
"id": "1125851192930836480", | |
"type": "reply", | |
"screen_name": "GiorgiaLodi" | |
}, | |
{ | |
"id": "1125873542137032709", | |
"type": "reply", | |
"screen_name": "simonealiprandi" | |
}, | |
{ | |
"id": "1126015706582147072", | |
"type": "reply", | |
"screen_name": "matt_fortini" | |
}, | |
{ | |
"id": "1126021068932698112", | |
"type": "reply", | |
"screen_name": "simonealiprandi" | |
}, | |
{ | |
"id": "1126021677853360129", | |
"type": "reply", | |
"screen_name": "matt_fortini" | |
}, | |
{ | |
"id": "1126032800375873537", | |
"type": "reply", | |
"screen_name": "simonealiprandi" | |
}, | |
{ | |
"id": "1126033707075342336", | |
"type": "reply", | |
"screen_name": "GiorgiaLodi" | |
}, | |
{ | |
"id": "1126033403483238400", | |
"type": "reply", | |
"screen_name": "morenaragone" | |
}, | |
{ | |
"id": "1126034581323431938", | |
"type": "reply", | |
"screen_name": "MonicaPalmirani" | |
}, | |
{ | |
"id": "1126060778501623808", | |
"type": "reply", | |
"screen_name": "GiorgiaLodi" | |
}, | |
{ | |
"id": "1126033793134014469", | |
"type": "reply", | |
"screen_name": "GiorgiaLodi" | |
}, | |
{ | |
"id": "1126035442976079872", | |
"type": "reply", | |
"screen_name": "MonicaPalmirani" | |
}, | |
{ | |
"id": "1126060901382094848", | |
"type": "reply", | |
"screen_name": "GiorgiaLodi" | |
}, | |
{ | |
"id": "1126031532685176833", | |
"type": "reply", | |
"screen_name": "GiorgiaLodi" | |
}, | |
{ | |
"id": "1126016588501614593", | |
"type": "reply", | |
"screen_name": "GiorgiaLodi" | |
}, | |
{ | |
"id": "1126016470008381440", | |
"type": "reply", | |
"screen_name": "MonicaPalmirani" | |
}, | |
{ | |
"id": "1126017169966477312", | |
"type": "reply", | |
"screen_name": "morenaragone" | |
}, | |
{ | |
"id": "1126017434534711296", | |
"type": "reply", | |
"screen_name": "MonicaPalmirani" | |
}, | |
{ | |
"id": "1126016838113034240", | |
"type": "reply", | |
"screen_name": "GiorgiaLodi" | |
}, | |
{ | |
"id": "1126017103276978181", | |
"type": "reply", | |
"screen_name": "MonicaPalmirani" | |
}, | |
{ | |
"id": "1126038511595991040", | |
"type": "reply", | |
"screen_name": "giovannigentili" | |
}, | |
{ | |
"id": "1126061920602198016", | |
"type": "reply", | |
"screen_name": "GiorgiaLodi" | |
}, | |
{ | |
"id": "1126063655391584256", | |
"type": "reply", | |
"screen_name": "GiorgiaLodi" | |
}, | |
{ | |
"id": "1126064194250350593", | |
"type": "reply", | |
"screen_name": "matt_fortini" | |
}, | |
{ | |
"id": "1126044474709352448", | |
"type": "reply", | |
"screen_name": "MonicaPalmirani" | |
}, | |
{ | |
"id": "1126045847253389312", | |
"type": "reply", | |
"screen_name": "giovannigentili" | |
}, | |
{ | |
"id": "1126046144407187457", | |
"type": "reply", | |
"screen_name": "morenaragone" | |
}, | |
{ | |
"id": "1126048408714776576", | |
"type": "reply", | |
"screen_name": "MonicaPalmirani" | |
}, | |
{ | |
"id": "1126029440528605184", | |
"type": "reply", | |
"screen_name": "GiorgiaLodi" | |
}, | |
{ | |
"id": "1126029869081559040", | |
"type": "reply", | |
"screen_name": "morenaragone" | |
}, | |
{ | |
"id": "1126030015815200768", | |
"type": "reply", | |
"screen_name": "GiorgiaLodi" | |
}, | |
{ | |
"id": "1126030521677561856", | |
"type": "reply", | |
"screen_name": "morenaragone" | |
}, | |
{ | |
"id": "1126030945113473029", | |
"type": "reply", | |
"screen_name": "GiorgiaLodi" | |
}, | |
{ | |
"id": "1126014820791332864", | |
"type": "reply", | |
"screen_name": "GiorgiaLodi" | |
}, | |
{ | |
"id": "1126028503118430209", | |
"type": "reply", | |
"screen_name": "aborruso" | |
}, | |
{ | |
"id": "1126022374015500288", | |
"type": "reply", | |
"screen_name": "giovannigentili" | |
}, | |
{ | |
"id": "1125411797899542534", | |
"type": "reply", | |
"screen_name": "matt_fortini" | |
}, | |
{ | |
"id": "1125400463946518528", | |
"type": "reply", | |
"screen_name": "napo" | |
}, | |
{ | |
"id": "1125398159629406215", | |
"type": "reply", | |
"screen_name": "GiorgiaLodi" | |
}, | |
{ | |
"id": "1125398471186493440", | |
"type": "reply", | |
"screen_name": "MonicaPalmirani" | |
}, | |
{ | |
"id": "1125400361483800577", | |
"type": "reply", | |
"screen_name": "GiorgiaLodi" | |
}, | |
{ | |
"id": "1125412186086572033", | |
"type": "reply", | |
"screen_name": "Piersoft" | |
}, | |
{ | |
"id": "1125418788709707776", | |
"type": "reply", | |
"screen_name": "GiorgiaLodi" | |
}, | |
{ | |
"id": "1125418853511696384", | |
"type": "reply", | |
"screen_name": "GiorgiaLodi" | |
}, | |
{ | |
"id": "1125398124636381184", | |
"type": "reply", | |
"screen_name": "MonicaPalmirani" | |
} | |
], | |
"links": [ | |
{ | |
"source": "1126001087792676864", | |
"target": "1125396760271179777", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126004676598620160", | |
"target": "1126001087792676864", | |
"type": "reply" | |
}, | |
{ | |
"source": "1125823561996877826", | |
"target": "1125396760271179777", | |
"type": "reply" | |
}, | |
{ | |
"source": "1125838865732919297", | |
"target": "1125823561996877826", | |
"type": "reply" | |
}, | |
{ | |
"source": "1125840097587486720", | |
"target": "1125838865732919297", | |
"type": "reply" | |
}, | |
{ | |
"source": "1125989399538302976", | |
"target": "1125840097587486720", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126002925732601856", | |
"target": "1125989399538302976", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126003651099725824", | |
"target": "1126002925732601856", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126015362670235648", | |
"target": "1126003651099725824", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126018061734174722", | |
"target": "1126015362670235648", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126028000464601088", | |
"target": "1126018061734174722", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126019268221513733", | |
"target": "1126018061734174722", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126029042833137665", | |
"target": "1126019268221513733", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126020349592776705", | |
"target": "1126019268221513733", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126020884928577537", | |
"target": "1126020349592776705", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126028949757341696", | |
"target": "1126020884928577537", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126029698079842304", | |
"target": "1126028949757341696", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126045236508221441", | |
"target": "1126029698079842304", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126029903000948736", | |
"target": "1126029698079842304", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126021309664780288", | |
"target": "1126020884928577537", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126020630938304512", | |
"target": "1126020349592776705", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126032258161418240", | |
"target": "1126020630938304512", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126032572180463616", | |
"target": "1126032258161418240", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126021579031363584", | |
"target": "1126020630938304512", | |
"type": "reply" | |
}, | |
{ | |
"source": "1125841043889455104", | |
"target": "1125840097587486720", | |
"type": "reply" | |
}, | |
{ | |
"source": "1125996706171105280", | |
"target": "1125841043889455104", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126008771879276544", | |
"target": "1125996706171105280", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126010426435809280", | |
"target": "1126008771879276544", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126018936783429632", | |
"target": "1126010426435809280", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126021080932585472", | |
"target": "1126018936783429632", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126020255724208128", | |
"target": "1126018936783429632", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126035265565409280", | |
"target": "1126020255724208128", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126044388138913793", | |
"target": "1126035265565409280", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126060071002279936", | |
"target": "1126044388138913793", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126063424755122176", | |
"target": "1126060071002279936", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126065438784479232", | |
"target": "1126063424755122176", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126066008320561152", | |
"target": "1126065438784479232", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126067335213797377", | |
"target": "1126066008320561152", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126067612792840194", | |
"target": "1126067335213797377", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126060636302188544", | |
"target": "1126060071002279936", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126062713216675841", | |
"target": "1126060636302188544", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126064120015523840", | |
"target": "1126062713216675841", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126066352836546560", | |
"target": "1126064120015523840", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126068658395021312", | |
"target": "1126066352836546560", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126069072930770944", | |
"target": "1126068658395021312", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126068126070788096", | |
"target": "1126066352836546560", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126064591002329088", | |
"target": "1126064120015523840", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126066481886842880", | |
"target": "1126064591002329088", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126068589717532672", | |
"target": "1126066481886842880", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126044078297288704", | |
"target": "1126035265565409280", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126064948470218753", | |
"target": "1126044078297288704", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126065235436146688", | |
"target": "1126064948470218753", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126066330908729345", | |
"target": "1126065235436146688", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126045073039400960", | |
"target": "1126044078297288704", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126064757646200832", | |
"target": "1126045073039400960", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126065540945125376", | |
"target": "1126064757646200832", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126045280267395072", | |
"target": "1126045073039400960", | |
"type": "reply" | |
}, | |
{ | |
"source": "1125843384793477120", | |
"target": "1125841043889455104", | |
"type": "reply" | |
}, | |
{ | |
"source": "1125879581305712640", | |
"target": "1125843384793477120", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126014987862978560", | |
"target": "1125879581305712640", | |
"type": "reply" | |
}, | |
{ | |
"source": "1125846267047940096", | |
"target": "1125843384793477120", | |
"type": "reply" | |
}, | |
{ | |
"source": "1125851192930836480", | |
"target": "1125846267047940096", | |
"type": "reply" | |
}, | |
{ | |
"source": "1125873542137032709", | |
"target": "1125851192930836480", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126015706582147072", | |
"target": "1125873542137032709", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126021068932698112", | |
"target": "1126015706582147072", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126021677853360129", | |
"target": "1126021068932698112", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126032800375873537", | |
"target": "1126021677853360129", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126033707075342336", | |
"target": "1126032800375873537", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126033403483238400", | |
"target": "1126032800375873537", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126034581323431938", | |
"target": "1126033403483238400", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126060778501623808", | |
"target": "1126034581323431938", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126033793134014469", | |
"target": "1126033403483238400", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126035442976079872", | |
"target": "1126033793134014469", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126060901382094848", | |
"target": "1126035442976079872", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126031532685176833", | |
"target": "1126021677853360129", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126016588501614593", | |
"target": "1126015706582147072", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126016470008381440", | |
"target": "1126015706582147072", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126017169966477312", | |
"target": "1126016470008381440", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126017434534711296", | |
"target": "1126017169966477312", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126016838113034240", | |
"target": "1126016470008381440", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126017103276978181", | |
"target": "1126016838113034240", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126038511595991040", | |
"target": "1126017103276978181", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126061920602198016", | |
"target": "1126038511595991040", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126063655391584256", | |
"target": "1126061920602198016", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126064194250350593", | |
"target": "1126063655391584256", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126044474709352448", | |
"target": "1126038511595991040", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126045847253389312", | |
"target": "1126044474709352448", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126046144407187457", | |
"target": "1126045847253389312", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126048408714776576", | |
"target": "1126046144407187457", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126029440528605184", | |
"target": "1126017103276978181", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126029869081559040", | |
"target": "1126029440528605184", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126030015815200768", | |
"target": "1126029869081559040", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126030521677561856", | |
"target": "1126030015815200768", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126030945113473029", | |
"target": "1126030521677561856", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126014820791332864", | |
"target": "1125873542137032709", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126028503118430209", | |
"target": "1126014820791332864", | |
"type": "reply" | |
}, | |
{ | |
"source": "1126022374015500288", | |
"target": "1126014820791332864", | |
"type": "reply" | |
}, | |
{ | |
"source": "1125411797899542534", | |
"target": "1125396760271179777", | |
"type": "reply" | |
}, | |
{ | |
"source": "1125400463946518528", | |
"target": "1125396760271179777", | |
"type": "reply" | |
}, | |
{ | |
"source": "1125398159629406215", | |
"target": "1125396760271179777", | |
"type": "reply" | |
}, | |
{ | |
"source": "1125398471186493440", | |
"target": "1125398159629406215", | |
"type": "reply" | |
}, | |
{ | |
"source": "1125400361483800577", | |
"target": "1125398471186493440", | |
"type": "reply" | |
}, | |
{ | |
"source": "1125412186086572033", | |
"target": "1125400361483800577", | |
"type": "reply" | |
}, | |
{ | |
"source": "1125418788709707776", | |
"target": "1125412186086572033", | |
"type": "reply" | |
}, | |
{ | |
"source": "1125418853511696384", | |
"target": "1125418788709707776", | |
"type": "reply" | |
}, | |
{ | |
"source": "1125398124636381184", | |
"target": "1125396760271179777", | |
"type": "reply" | |
} | |
] | |
}; | |
var link = svg.append("g") | |
.attr("class", "links") | |
.selectAll("line") | |
.data(graph.links) | |
.enter().append("line") | |
.attr("class", function(d) { return d.type; }); | |
var node = svg.append("g") | |
.attr("class", "nodes") | |
.selectAll("circle") | |
.data(graph.nodes) | |
.enter().append("circle") | |
.attr("r", 5) | |
.attr("class", function(d) { return d.type; }) | |
.call(d3.drag() | |
.on("start", dragstarted) | |
.on("drag", dragged) | |
.on("end", dragended)); | |
node.append("title") | |
.text(function(d) { return d.id; }); | |
node.on("click", function(d) { | |
$("#tweet").empty(); | |
var rect = this.getBoundingClientRect(); | |
var paneHeight = d.type == "retweet" ? 50 : 200; | |
var paneWidth = d.type == "retweet" ? 75 : 500; | |
var left = rect.x - paneWidth / 2; | |
if (rect.y > height / 2) { | |
var top = rect.y - paneHeight; | |
} else { | |
var top = rect.y + 10; | |
} | |
var tweet = $("#tweet"); | |
tweet.css({left: left, top: top}); | |
if (d.type == "retweet") { | |
twttr.widgets.createFollowButton(d.screen_name, tweet[0], {size: "large"}); | |
} else { | |
twttr.widgets.createTweet(d.id, tweet[0], {conversation: "none"}); | |
} | |
d3.event.stopPropagation(); | |
}); | |
svg.on("click", function(d) { | |
$("#tweet").empty(); | |
}); | |
simulation | |
.nodes(graph.nodes) | |
.on("tick", ticked); | |
simulation.force("link") | |
.links(graph.links); | |
function ticked() { | |
link | |
.attr("x1", function(d) { return d.source.x; }) | |
.attr("y1", function(d) { return d.source.y; }) | |
.attr("x2", function(d) { return d.target.x; }) | |
.attr("y2", function(d) { return d.target.y; }); | |
node | |
.attr("cx", function(d) { return d.x; }) | |
.attr("cy", function(d) { return d.y; }); | |
} | |
function dragstarted(d) { | |
if (!d3.event.active) simulation.alphaTarget(0.3).restart(); | |
d.fx = d.x; | |
d.fy = d.y; | |
} | |
function dragged(d) { | |
d.fx = d3.event.x; | |
d.fy = d3.event.y; | |
} | |
function dragended(d) { | |
if (!d3.event.active) simulation.alphaTarget(0); | |
d.fx = null; | |
d.fy = null; | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment