Skip to content

Instantly share code, notes, and snippets.

@mschober
Created November 2, 2012 23:21
Show Gist options
  • Save mschober/4004982 to your computer and use it in GitHub Desktop.
Save mschober/4004982 to your computer and use it in GitHub Desktop.
just another inlet to tributary
{"endpoint":"","display":"svg","public":true,"require":[],"tab":"edit","display_percent":0.6589858314690531,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01}
tributary.finance_data = {"Income":{"column_names":["date","amount"],"name":"Income","elements":[{"date":"1/1/2012","amount":"$11503.90","rowNumber":1},{"date":"1/9/2012","amount":"$150","rowNumber":2},{"date":"1/10/2012","amount":"$300","rowNumber":3},{"date":"40926","amount":"10","rowNumber":4},{"date":"1/24/2012","amount":"$100","rowNumber":5},{"date":"1/24/2012","amount":"$300","rowNumber":6},{"date":"1/27/2012","amount":"$93","rowNumber":7},{"date":"1/17/2012","amount":"$20000","rowNumber":8},{"date":"2/6/2012","amount":"$200","rowNumber":9},{"date":"2/6/2012","amount":"$442.50","rowNumber":10},{"date":"1/31/2012","amount":"$0.96","rowNumber":11},{"date":"2/7/2012","amount":"$310","rowNumber":12},{"date":"2/7/2012","amount":"$50","rowNumber":13},{"date":"2/8/2012","amount":"$200","rowNumber":14},{"date":"40947","amount":"10","rowNumber":15},{"date":"2/15/2012","amount":"$25","rowNumber":16},{"date":"2/18/2012","amount":"$500","rowNumber":17},{"date":"2/16/2012","amount":"$2000","rowNumber":18},{"date":"2/29/2012","amount":"$1.27","rowNumber":19},{"date":"3/31/2012","amount":"$1.10","rowNumber":20},{"date":"4/16/2012","amount":"$1370","rowNumber":21},{"date":"4/28/2012","amount":"$100","rowNumber":22},{"date":"4/30/2012","amount":"$0.95","rowNumber":23},{"date":"5/31/2012","amount":"$0.85","rowNumber":24},{"date":"5/31/2012","amount":"$2000","rowNumber":25},{"date":"6/30/2012","amount":"$0.77","rowNumber":26},{"date":"6/5/2012","amount":"$1800","rowNumber":27},{"date":"7/31/2012","amount":"$0.73","rowNumber":28},{"date":"8/31/2012","amount":"$0.66","rowNumber":29}]},"Expenses Summary":{"column_names":["purpose","amount"],"name":"Expenses Summary","elements":[{"purpose":"#NAME?","amount":"#VALUE!","rowNumber":1},{"purpose":"#VALUE!","amount":"#VALUE!","rowNumber":2},{"purpose":"#VALUE!","amount":"#VALUE!","rowNumber":3},{"purpose":"#VALUE!","amount":"#VALUE!","rowNumber":4},{"purpose":"#VALUE!","amount":"#VALUE!","rowNumber":5},{"purpose":"#VALUE!","amount":"#VALUE!","rowNumber":6},{"purpose":"#VALUE!","amount":"#VALUE!","rowNumber":7},{"purpose":"#VALUE!","amount":"#VALUE!","rowNumber":8},{"purpose":"#VALUE!","amount":"#VALUE!","rowNumber":9},{"purpose":"#VALUE!","amount":"#VALUE!","rowNumber":10},{"purpose":"#VALUE!","amount":"#VALUE!","rowNumber":11},{"purpose":"#VALUE!","amount":"#VALUE!","rowNumber":12},{"purpose":"#VALUE!","amount":"#VALUE!","rowNumber":13},{"purpose":"#VALUE!","amount":"#VALUE!","rowNumber":14},{"purpose":"#VALUE!","amount":"#VALUE!","rowNumber":15},{"purpose":"#VALUE!","amount":"#VALUE!","rowNumber":16},{"purpose":"#VALUE!","amount":"#VALUE!","rowNumber":17},{"purpose":"#VALUE!","amount":"#VALUE!","rowNumber":18},{"purpose":"#VALUE!","amount":"#VALUE!","rowNumber":19},{"purpose":"#VALUE!","amount":"#VALUE!","rowNumber":20},{"purpose":"#VALUE!","amount":"#VALUE!","rowNumber":21},{"purpose":"#VALUE!","amount":"#VALUE!","rowNumber":22},{"purpose":"#VALUE!","amount":"#VALUE!","rowNumber":23},{"purpose":"#VALUE!","amount":"#VALUE!","rowNumber":24}]},"Expenses":{"column_names":["check","date","amount","purpose"],"name":"Expenses","elements":[{"check":"150","date":"1/1/2012","amount":"$77.85","purpose":"admin","rowNumber":1},{"check":"151","date":"1/1/2012","amount":"$109.21","purpose":"education","rowNumber":2},{"check":"152","date":"1/1/2012","amount":"$149.56","purpose":"education","rowNumber":3},{"check":"153","date":"1/1/2012","amount":"200","purpose":"rent","rowNumber":4},{"check":"154","date":"1/1/2012","amount":"$171.11","purpose":"food","rowNumber":5},{"check":"155","date":"1/1/2012","amount":"$93.66","purpose":"food","rowNumber":6},{"check":"156","date":"1/12/2012","amount":"$60.70","purpose":"transportation","rowNumber":7},{"check":"157","date":"1/18/2012","amount":"$282.73","purpose":"computer","rowNumber":8},{"check":"158","date":"1/18/2012","amount":"$228.99","purpose":"computer","rowNumber":9},{"check":"159","date":"1/18/2012","amount":"$117.82","purpose":"food","rowNumber":10},{"check":"160","date":"1/18/2012","amount":"$267.12","purpose":"food","rowNumber":11},{"check":"161","date":"1/27/2012","amount":"$568.26","purpose":"food","rowNumber":12},{"check":"162","date":"1/27/2012","amount":"$50","purpose":"food","rowNumber":13},{"check":"163","date":"2/2/2012","amount":"$48","purpose":"telephone","rowNumber":14},{"check":"164","date":"40941","amount":"200","purpose":"rent","rowNumber":15},{"check":"165","date":"2/2/2012","amount":"$200","purpose":"printing/signs","rowNumber":16},{"check":"---","date":"1/17/2012","amount":"$10","purpose":"admin","rowNumber":17},{"check":"","date":"2/6/2012","amount":"$14.08","purpose":"admin","rowNumber":18},{"check":"166","date":"2/7/2012","amount":"$42.40","purpose":"printing/signs","rowNumber":19},{"check":"167","date":"2/7/2012","amount":"$189.56","purpose":"food","rowNumber":20},{"check":"168","date":"2/7/2012","amount":"$44.08","purpose":"food","rowNumber":21},{"check":"169","date":"2/7/2012","amount":"$384.24","purpose":"text","rowNumber":22},{"check":"170","date":"2/7/2012","amount":"$200","purpose":"printing/signs","rowNumber":23},{"check":"171","date":"2/7/2012","amount":"$162.01","purpose":"video","rowNumber":24},{"check":"172","date":"2/7/2012","amount":"$399.85","purpose":"food","rowNumber":25},{"check":"173","date":"2/8/2012","amount":"$308.82","purpose":"education","rowNumber":26},{"check":"174","date":"2/15/2012","amount":"$183.31","purpose":"food","rowNumber":27},{"check":"175","date":"2/15/2012","amount":"$29.13","purpose":"blankets","rowNumber":28},{"check":"176","date":"2/15/2012","amount":"$57.91","purpose":"blankets","rowNumber":29},{"check":"177","date":"2/15/2012","amount":"$169","purpose":"printing/signs","rowNumber":30},{"check":"178","date":"2/15/2012","amount":"$176.08","purpose":"printing/signs","rowNumber":31},{"check":"179","date":"2/15/2012","amount":"$495.50","purpose":"printing/signs","rowNumber":32},{"check":"180","date":"2/15/2012","amount":"$296","purpose":"printing/signs","rowNumber":33},{"check":"181","date":"2/17/2012","amount":"$561.15","purpose":"printing/signs","rowNumber":34},{"check":"182","date":"2/22/2012","amount":"$138.48","purpose":"food","rowNumber":35},{"check":"183","date":"2/22/2012","amount":"$118.67","purpose":"supplies","rowNumber":36},{"check":"184","date":"2/22/2012","amount":"$750","purpose":"printing/signs","rowNumber":37},{"check":"185","date":"2/22/2012","amount":"$32.57","purpose":"printing/signs","rowNumber":38},{"check":"186","date":"2/24/2012","amount":"$186.90","purpose":"food","rowNumber":39},{"check":"187","date":"2/24/2012","amount":"$2500","purpose":"transportation","rowNumber":40},{"check":"188","date":"3/2/2012","amount":"$158.24","purpose":"food","rowNumber":41},{"check":"189","date":"3/2/2012","amount":"$243.70","purpose":"supplies","rowNumber":42},{"check":"190","date":"40970","amount":"200","purpose":"rent","rowNumber":43},{"check":"191","date":"3/2/2012","amount":"void","purpose":"rent/utilities","rowNumber":44},{"check":"192","date":"3/9/2012","amount":"$95.73","purpose":"supplies","rowNumber":45},{"check":"193","date":"3/9/2012","amount":"$300","purpose":"transportation","rowNumber":46},{"check":"194","date":"3/9/2012","amount":"$24","purpose":"transportation","rowNumber":47},{"check":"195","date":"3/9/2012","amount":"$210.70","purpose":"transportation","rowNumber":48},{"check":"196","date":"3/9/2012","amount":"$8.13","purpose":"supplies","rowNumber":49},{"check":"197","date":"40977","amount":"655.45","purpose":"rent/utilities","rowNumber":50},{"check":"198","date":"3/9/2012","amount":"$155.16","purpose":"food","rowNumber":51},{"check":"199","date":"3/16/2012","amount":"$267.59","purpose":"food","rowNumber":52},{"check":"200","date":"3/23/2012","amount":"$916.50","purpose":"food","rowNumber":53},{"check":"201","date":"3/23/2012","amount":"$229.75","purpose":"printing/signs","rowNumber":54},{"check":"202","date":"3/23/2012","amount":"$111.23","purpose":"supplies","rowNumber":55},{"check":"203","date":"40998","amount":"200","purpose":"rent","rowNumber":56},{"check":"204","date":"3/30/2012","amount":"$259.39","purpose":"food","rowNumber":57},{"check":"205","date":"4/10/2012","amount":"$244.97","purpose":"food","rowNumber":58},{"check":"206","date":"4/10/2012","amount":"$415.35","purpose":"supplies","rowNumber":59},{"check":"207","date":"4/10/2012","amount":"$10","purpose":"food","rowNumber":60},{"check":"208","date":"4/16/2012","amount":"$269.50","purpose":"food","rowNumber":61},{"check":"209","date":"4/16/2012","amount":"$18.81","purpose":"printing/signs","rowNumber":62},{"check":"210","date":"4/16/2012","amount":"$83.05","purpose":"printing/signs","rowNumber":63},{"check":"211","date":"4/28/2012","amount":"$599.91","purpose":"medical","rowNumber":64},{"check":"212","date":"4/30/2012","amount":"$475.01","purpose":"food","rowNumber":65},{"check":"213","date":"4/30/2012","amount":"$106.67","purpose":"phone","rowNumber":66},{"check":"214","date":"4/30/2012","amount":"$975","purpose":"printing/signs","rowNumber":67},{"check":"215","date":"5/7/2012","amount":"$217.50","purpose":"printing/signs","rowNumber":68},{"check":"216","date":"5/7/2012","amount":"$1126.52","purpose":"food/supplies","rowNumber":69},{"check":"217","date":"5/7/2012","amount":"$23.49","purpose":"medical","rowNumber":70},{"check":"218","date":"5/15/2012","amount":"$328.90","purpose":"food","rowNumber":71},{"check":"219","date":"5/15/2012","amount":"$206.63","purpose":"printing/signs","rowNumber":72},{"check":"220","date":"5/15/2012","amount":"$167.51","purpose":"food/supplies","rowNumber":73},{"check":"221","date":"5/15/2012","amount":"$46.68","purpose":"food/supplies","rowNumber":74},{"check":"222","date":"5/15/2012","amount":"$299.14","purpose":"printing/signs","rowNumber":75},{"check":"223","date":"5/15/2012","amount":"$424","purpose":"printing/signs","rowNumber":76},{"check":"224","date":"41059","amount":"200","purpose":"rent","rowNumber":77},{"check":"225","date":"5/30/2012","amount":"$82.45","purpose":"food and printing","rowNumber":78},{"check":"226","date":"5/30/2012","amount":"$585.73","purpose":"transportation","rowNumber":79},{"check":"227","date":"5/30/2012","amount":"$456.83","purpose":"food and outreach","rowNumber":80},{"check":"228","date":"5/30/2012","amount":"$176.84","purpose":"food","rowNumber":81},{"check":"229","date":"5/30/2012","amount":"$297.99","purpose":"food","rowNumber":82},{"check":"230","date":"5/30/2012","amount":"$150.71","purpose":"food","rowNumber":83},{"check":"231","date":"5/30/2012","amount":"$4.50","purpose":"food","rowNumber":84},{"check":"232","date":"5/30/2012","amount":"$631.39","purpose":"food and printing","rowNumber":85},{"check":"233","date":"41060","amount":"200","purpose":"rent","rowNumber":86},{"check":"234","date":"6/21/2012","amount":"$23.49","purpose":"medical","rowNumber":87},{"check":"235","date":"6/21/2012","amount":"$375.46","purpose":"food","rowNumber":88},{"check":"236","date":"void","amount":"","purpose":"","rowNumber":89},{"check":"237","date":"41081","amount":"200","purpose":"rent","rowNumber":90},{"check":"238","date":"6/21/2012","amount":"$127.34","purpose":"printing/signs","rowNumber":91},{"check":"239","date":"6/21/2012","amount":"$76.44","purpose":"food and printing","rowNumber":92},{"check":"240","date":"6/21/2012","amount":"$30.85","purpose":"printing/signs","rowNumber":93},{"check":"241","date":"6/21/2012","amount":"$610.76","purpose":"medical","rowNumber":94},{"check":"242","date":"6/21/2012","amount":"$23.26","purpose":"medical","rowNumber":95},{"check":"243","date":"6/21/2012","amount":"151.16","purpose":"printing/signs","rowNumber":96},{"check":"244","date":"41092","amount":"200","purpose":"rent","rowNumber":97},{"check":"245","date":"7/2/2012","amount":"$25.30","purpose":"communications","rowNumber":98},{"check":"246","date":"7/2/2012","amount":"$182.29","purpose":"food","rowNumber":99},{"check":"247","date":"7/2/2012","amount":"$170.04","purpose":"printing/signs","rowNumber":100},{"check":"transfer","date":"7/19/2012","amount":"$8.85","purpose":"admin","rowNumber":101},{"check":"transfer","date":"7/26/2012","amount":"$22.36","purpose":"admin","rowNumber":102},{"check":"248","date":"41127","amount":"200","purpose":"rent","rowNumber":103},{"check":"249","date":"41127","amount":"200","purpose":"rent","rowNumber":104},{"check":"250","date":"8/6/2012","amount":"---","purpose":"admin","rowNumber":105},{"check":"251","date":"8/6/2012","amount":"$839","purpose":"food","rowNumber":106},{"check":"252","date":"8/6/2012","amount":"$105","purpose":"medical","rowNumber":107},{"check":"253","date":"8/6/2012","amount":"$189.55","purpose":"food","rowNumber":108},{"check":"254","date":"8/17/2012","amount":"$635.96","purpose":"supplies and food","rowNumber":109},{"check":"255","date":"8/17/2012","amount":"$97.42","purpose":"supplies","rowNumber":110},{"check":"256","date":"41138","amount":"220","purpose":"rent","rowNumber":111},{"check":"257","date":"8/17/2012","amount":"$531.71","purpose":"toilet with ADA access","rowNumber":112},{"check":"258","date":"8/17/2012","amount":"$134.37","purpose":"admin","rowNumber":113},{"check":"259","date":"41170","amount":"200","purpose":"rent","rowNumber":114},{"check":"260","date":"41170","amount":"200","purpose":"rent","rowNumber":115},{"check":"261","date":"9/18/2012","amount":"$374.54","purpose":"printing and supplies","rowNumber":116},{"check":"262","date":"9/18/2012","amount":"$96.61","purpose":"food/supplies","rowNumber":117},{"check":"263","date":"41170","amount":"200","purpose":"rent","rowNumber":118}]}}
console.log(tributary.finance_data)
console.log(tributary.elementData);
var focalNodeID = "N1";
var nodeSet = [
{id: "N1", name: "Node 1", type: "Type 1", hlink: "http://www.if4it.com"},
{id: "N2", name: "Node 2", type: "Type 3", hlink: "http://www.if4it.com/glossary.html"},
{id: "N3", name: "Node 3", type: "Type 4", hlink: "http://www.if4it.com/resources.html"},
{id: "N4", name: "Node 4", type: "Type 5", hlink: "http://www.if4it.com/taxonomy.html"},
{id: "N5", name: "Node 5", type: "Type 1", hlink: "http://www.if4it.com/disciplines.html"},
{id: "N6", name: "Node 6", type: "Type 2", hlink: "http://www.if4it.com"},
{id: "N7", name: "Node 7", type: "Type 3", hlink: "http://www.if4it.com/glossary.html"},
{id: "N8", name: "Node 8", type: "Type 4", hlink: "http://www.if4it.com/resources.html"},
{id: "N9", name: "Node 9", type: "Type 5", hlink: "http://www.if4it.com/taxonomy.html"},
{id: "N10", name: "Node 10", type: "Type 1", hlink: "http://www.if4it.com/disciplines.html"},
{id: "N11", name: "Node 11", type: "Type 2", hlink: "http://www.if4it.com"},
{id: "N12", name: "Node 12", type: "Type 3", hlink: "http://www.if4it.com/glossary.html"},
{id: "N13", name: "Node 13", type: "Type 4", hlink: "http://www.if4it.com/resources.html"},
{id: "N14", name: "Node 14", type: "Type 5", hlink: "http://www.if4it.com/taxonomy.html"},
{id: "N15", name: "Node 15", type: "Type 1", hlink: "http://www.if4it.com/disciplines.html"},
{id: "N16", name: "Node 16", type: "Type 3", hlink: "http://www.if4it.com"},
{id: "N17", name: "Node 17", type: "Type 1", hlink: "http://www.if4it.com/glossary.html"},
{id: "N18", name: "Node 18", type: "Type 1", hlink: "http://www.if4it.com/glossary.html"},
{id: "N19", name: "Node 19", type: "Type 4", hlink: "http://www.if4it.com/glossary.html"},
{id: "N20", name: "Node 20", type: "Type 4", hlink: "http://www.if4it.com/glossary.html"},
{id: "N21", name: "Node 21", type: "Type 4", hlink: "http://www.if4it.com/glossary.html"},
{id: "N22", name: "Node 22", type: "Type 1", hlink: "http://www.if4it.com/glossary.html"},
{id: "N23", name: "Node 23", type: "Type 5", hlink: "http://www.if4it.com/glossary.html"},
{id: "N24", name: "Node 24", type: "Type 5", hlink: "http://www.if4it.com/glossary.html"},
{id: "N25", name: "Node 25", type: "Type 5", hlink: "http://www.if4it.com/glossary.html"},
{id: "N26", name: "Node 26", type: "Type 5", hlink: "http://www.if4it.com/glossary.html"},
{id: "N27", name: "Node 27", type: "Type 5", hlink: "http://www.if4it.com/glossary.html"},
{id: "N28", name: "Node 28", type: "Type 5", hlink: "http://www.if4it.com/glossary.html"},
{id: "N29", name: "Node 29", type: "Type 5", hlink: "http://www.if4it.com/glossary.html"}
];
// Embedding inline like this works
var linkSet = [
{sourceId: "N1", linkName: "Relationship 1", targetId: "N2"},
{sourceId: "N3", linkName: "Relationship 2", targetId: "N1"},
{sourceId: "N4", linkName: "Relationship 3", targetId: "N1"},
{sourceId: "N1", linkName: "Relationship 4", targetId: "N5"},
{sourceId: "N6", linkName: "Relationship 5", targetId: "N1"},
{sourceId: "N1", linkName: "Relationship 6", targetId: "N7"},
{sourceId: "N1", linkName: "Relationship 7", targetId: "N8"},
{sourceId: "N9", linkName: "Relationship 8", targetId: "N1"},
{sourceId: "N1", linkName: "Relationship 9", targetId: "N10"},
{sourceId: "N11", linkName: "Relationship 10", targetId: "N1"},
{sourceId: "N1", linkName: "Relationship 11", targetId: "N12"},
{sourceId: "N13", linkName: "Relationship 12", targetId: "N1"},
{sourceId: "N1", linkName: "Relationship 13", targetId: "N14"},
{sourceId: "N1", linkName: "Relationship 14", targetId: "N15"},
{sourceId: "N16", linkName: "Relationship 15", targetId: "N1"},
{sourceId: "N17", linkName: "Relationship 16", targetId: "N1"},
{sourceId: "N18", linkName: "Relationship 17", targetId: "N1"},
{sourceId: "N19", linkName: "Relationship 18", targetId: "N1"},
{sourceId: "N20", linkName: "Relationship 19", targetId: "N1"},
{sourceId: "N21", linkName: "Relationship 20", targetId: "N1"},
{sourceId: "N22", linkName: "Relationship 21", targetId: "N1"},
{sourceId: "N1", linkName: "Relationship 22", targetId: "N23"},
{sourceId: "N1", linkName: "Relationship 23", targetId: "N24"},
{sourceId: "N24", linkName: "Relationship 24", targetId: "N25"},
{sourceId: "N24", linkName: "Relationship 25", targetId: "N26"},
{sourceId: "N24", linkName: "Relationship 26", targetId: "N27"},
{sourceId: "N24", linkName: "Relationship 27", targetId: "N28"},
{sourceId: "N24", linkName: "Relationship 28", targetId: "N29"},
];
var width = 1044,
height = 922,
centerNodeSize = 50;
nodeSize = 10;
colorScale = d3.scale.category20();
var svgCanvas = d3.select("svg")
.attr("width", width)
.attr("height", height);
var node_hash = [];
var type_hash = [];
nodeSet.forEach(function(d, i) {
node_hash[d.id] = d;
type_hash[d.type] = d.type;
});
// Append the source object node and the target object node to each link
linkSet.forEach(function(d, i) {
d.source = node_hash[d.sourceId];
d.target = node_hash[d.targetId];
if (d.sourceId == focalNodeID)
{ d.direction = "OUT"; }
else
{ d.direction = "IN"; }
});
// Create a force layout and bind Nodes and Links
var force = d3.layout.force()
.charge(-4673)
.nodes(nodeSet)
.links(linkSet)
.size([width, height])
.linkDistance( function(d) { if (width < height) { return width*1/3; } else { return height*1/3 } } ) // Controls edge length
.on("tick", tick)
.start();
// Draw lines for Links between Nodes
var link = svgCanvas.selectAll(".gLink")
.data(force.links())
.enter().append("g")
.attr("class", "gLink")
.append("line")
.attr("class", "link")
.style("stroke", "#ccc")
.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; });
// Create Nodes
var node = svgCanvas.selectAll(".node")
.data(force.nodes())
.enter().append("g")
.attr("class", "node")
.on("mouseover", nodeMouseover)
.on("mouseout", nodeMouseout)
.call(force.drag);
// Append circles to Nodes
node.append("circle")
.attr("x", function(d) { return d.x; })
.attr("y", function(d) { return d.y; })
.attr("r", function(d) { if (d.id==focalNodeID) { return centerNodeSize; } else { return nodeSize; } } ) // Node radius
.style("fill", "White") // Make the nodes hollow looking
.style("stroke-width", 5) // Give the node strokes some thickness
.style("stroke", function(d, i) { colorVal = colorScale(i); return colorVal; } ) // Node stroke colors
.call(force.drag);
// Append text to Nodes
node.append("a")
.attr("xlink:href", function(d) { return d.hlink; })
.append("text")
.attr("x", function(d) { if (d.id==focalNodeID) { return 0; } else {return 20;} } )
.attr("y", function(d) { if (d.id==focalNodeID) { return 0; } else {return -10;} } )
.attr("text-anchor", function(d) { if (d.id==focalNodeID) {return "middle";} else {return "start";} })
.attr("font-family", "Arial, Helvetica, sans-serif")
.style("font", "normal 16px Arial")
.attr("fill", "Blue")
.attr("dy", ".35em")
.text(function(d) { return d.name; });
// Append text to Link edges
var linkText = svgCanvas.selectAll(".gLink")
.data(force.links())
.append("text")
.attr("font-family", "Arial, Helvetica, sans-serif")
.attr("x", function(d) {
if (d.target.x > d.source.x) { return (d.source.x + (d.target.x - d.source.x)/2); }
else { return (d.target.x + (d.source.x - d.target.x)/2); }
})
.attr("y", function(d) {
if (d.target.y > d.source.y) { return (d.source.y + (d.target.y - d.source.y)/2); }
else { return (d.target.y + (d.source.y - d.target.y)/2); }
})
.attr("fill", "Maroon")
.style("font", "normal 12px Arial")
.attr("dy", ".35em")
.text(function(d) { return d.linkName; });
function tick() {
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("transform", function(d) { return "translate(" + d.x + "," + d.y + ")"; });
linkText
.attr("x", function(d) {
if (d.target.x > d.source.x) { return (d.source.x + (d.target.x - d.source.x)/2); }
else { return (d.target.x + (d.source.x - d.target.x)/2); }
})
.attr("y", function(d) {
if (d.target.y > d.source.y) { return (d.source.y + (d.target.y - d.source.y)/2); }
else { return (d.target.y + (d.source.y - d.target.y)/2); }
});
}
function nodeMouseover() {
d3.select(this).select("circle").transition()
.duration(250)
.attr("r", function(d,i) { if(d.id==focalNodeID) {return 65;} else {return 15;} } );
d3.select(this).select("text").transition()
.duration(250)
.style("font", "bold 20px Arial")
.attr("fill", "Blue");
}
function nodeMouseout() {
d3.select(this).select("circle").transition()
.duration(250)
.attr("r", function(d,i) { if(d.id==focalNodeID) {return centerNodeSize;} else {return nodeSize;} } );
d3.select(this).select("text").transition()
.duration(250)
.style("font", "normal 16px Arial")
.attr("fill", "Blue");
}
tributary.elementData =
{
"elements":[
{"sourceId": "N1", "linkName": "Relationship 1", "targetId": "N2"},
{"sourceId": "N3", "linkName": "Relationship 2", "targetId": "N1"},
{"sourceId": "N4", "linkName": "Relationship 3", "targetId": "N1"},
{"sourceId": "N1", "linkName": "Relationship 4", "targetId": "N5"},
{"sourceId": "N6", "linkName": "Relationship 5", "targetId": "N1"},
{"sourceId": "N1", "linkName": "Relationship 6", "targetId": "N7"},
{"sourceId": "N1", "linkName": "Relationship 7", "targetId": "N8"},
{"sourceId": "N9", "linkName": "Relationship 8", "targetId": "N1"},
{"sourceId": "N1", "linkName": "Relationship 9", "targetId": "N10"},
{"sourceId": "N11", "linkName": "Relationship 10", "targetId": "N1"},
{"sourceId": "N1", "linkName": "Relationship 11", "targetId": "N12"},
{"sourceId": "N13", "linkName": "Relationship 12", "targetId": "N1"},
{"sourceId": "N1", "linkName": "Relationship 13", "targetId": "N14"},
{"sourceId": "N1", "linkName": "Relationship 14", "targetId": "N15"},
{"sourceId": "N16", "linkName": "Relationship 15", "targetId": "N1"},
{"sourceId": "N17", "linkName": "Relationship 16", "targetId": "N1"},
{"sourceId": "N18", "linkName": "Relationship 17", "targetId": "N1"},
{"sourceId": "N19", "linkName": "Relationship 18", "targetId": "N1"},
{"sourceId": "N20", "linkName": "Relationship 19", "targetId": "N1"},
{"sourceId": "N21", "linkName": "Relationship 20", "targetId": "N1"},
{"sourceId": "N22", "linkName": "Relationship 21", "targetId": "N1"},
{"sourceId": "N1", "linkName": "Relationship 22", "targetId": "N23"},
{"sourceId": "N1", "linkName": "Relationship 23", "targetId": "N24"},
{"sourceId": "N24", "linkName": "Relationship 24", "targetId": "N25"},
{"sourceId": "N24", "linkName": "Relationship 25", "targetId": "N26"},
{"sourceId": "N24", "linkName": "Relationship 26", "targetId": "N27"},
{"sourceId": "N24", "linkName": "Relationship 27", "targetId": "N28"},
{"sourceId": "N24", "linkName": "Relationship 28", "targetId": "N29"}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment