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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<meta charset="UTF-8">
|
| 3 |
+
<head>
|
| 4 |
+
<link rel = "stylesheet" href = "/app/ima-pipeline/assets/css/tree.css">
|
| 5 |
+
<link rel = "stylesheet" href = "/app/ima-pipeline/assets/css/div.css">
|
| 6 |
+
<link rel = "stylesheet" href = "/app/ima-pipeline/assets/css/side.css">
|
| 7 |
+
<style>
|
| 8 |
+
|
| 9 |
+
body {background-color:mintcream;}
|
| 10 |
+
</style>
|
| 11 |
+
</head>
|
| 12 |
+
|
| 13 |
+
<body>
|
| 14 |
+
<center>
|
| 15 |
+
<h1 style="color:black;">Causal text to Knowledge graph Taxonomy</h1>
|
| 16 |
+
</center>
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
<div class = "container">
|
| 20 |
+
<!-- load the d3.js library -->
|
| 21 |
+
<div class = "tree">
|
| 22 |
+
<script src="https://d3js.org/d3.v4.min.js"></script>
|
| 23 |
+
<script>
|
| 24 |
+
|
| 25 |
+
var treeData =
|
| 26 |
+
{"name": "Performance or Not", "children": [{"name": "Performance (P)", "children": [{"name": "Investors (INV)", "children": [{"name": "Accounting-based performance (INV1)"}, {"name": "Stock market-based performance (INV2)"}, {"name": "Survey-based performance (INV3)"}, {"name": "Growth-based performance (INV4)"}]}, {"name": "Customers (CUS)", "children": [{"name": "Customer commitment (CUS1)"}, {"name": "Customer satisfaction (CUS2)"}, {"name": "Brand recognition and reputation (CUS3)"}, {"name": "Product & service quality (CUS4)"}]}, {"name": "Employees (EMP)", "children": [{"name": "Employee commitment (EMP1)"}, {"name": "Employee satisfaction (EMP2)"}, {"name": "Employee compensation, protection and benefits (EMP3)"}, {"name": "Employee health (EMP4)"}]}, {"name": "Society (SOC)", "children": [{"name": "Symbolic socially responsible efforts (SOC1)"}, {"name": "Substantive social impact and performance (SOC2)"}, {"name": "Symbolic environmentally responsible efforts (SOC3)"}, {"name": "Substantive environmental impact and performance (SOC4)"}, {"name": "Uncategorized or combined (SOC5)"}]}, {"name": "Unclassified", "children":""}]}, {"name": "Non-performance", }]};
|
| 27 |
+
|
| 28 |
+
// Set the dimensions and margins of the diagram
|
| 29 |
+
var margin = {top: 20, right: 90, bottom: 30, left: 116},
|
| 30 |
+
width = 850- margin.left - margin.right,
|
| 31 |
+
height = 800 - margin.top - margin.bottom;
|
| 32 |
+
|
| 33 |
+
// append the svg object to the body of the page
|
| 34 |
+
// appends a 'group' element to 'svg'
|
| 35 |
+
// moves the 'group' element to the top left margin
|
| 36 |
+
var svg2 = d3.select("body").append("svg")
|
| 37 |
+
.attr("width", width + margin.right + margin.left)
|
| 38 |
+
.attr("height", height + margin.top + margin.bottom)
|
| 39 |
+
.append("g")
|
| 40 |
+
.attr("transform", "translate("
|
| 41 |
+
+ margin.left + "," + margin.top + ")");
|
| 42 |
+
|
| 43 |
+
var i = 0,
|
| 44 |
+
duration = 750,
|
| 45 |
+
root;
|
| 46 |
+
|
| 47 |
+
// declares a tree layout and assigns the size
|
| 48 |
+
var treemap = d3.tree().size([height, width]);
|
| 49 |
+
|
| 50 |
+
// Assigns parent, children, height, depth
|
| 51 |
+
root = d3.hierarchy(treeData, function(d) { return d.children; });
|
| 52 |
+
root.x0 = height / 2;
|
| 53 |
+
root.y0 = 0;
|
| 54 |
+
|
| 55 |
+
// Collapse after the second level
|
| 56 |
+
root.children.forEach(collapse);
|
| 57 |
+
|
| 58 |
+
update(root);
|
| 59 |
+
|
| 60 |
+
// Collapse the node and all it's children
|
| 61 |
+
function collapse(d) {
|
| 62 |
+
if(d.children) {
|
| 63 |
+
d._children = d.children
|
| 64 |
+
d._children.forEach(collapse)
|
| 65 |
+
d.children = null
|
| 66 |
+
}
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
function update(source) {
|
| 70 |
+
|
| 71 |
+
// Assigns the x and y position for the nodes
|
| 72 |
+
var treeData = treemap(root);
|
| 73 |
+
|
| 74 |
+
// Compute the new tree layout.
|
| 75 |
+
var nodes = treeData.descendants(),
|
| 76 |
+
links = treeData.descendants().slice(1);
|
| 77 |
+
|
| 78 |
+
// Normalize for fixed-depth.
|
| 79 |
+
nodes.forEach(function(d){ d.y = d.depth * 130});
|
| 80 |
+
|
| 81 |
+
// ****************** Nodes section ***************************
|
| 82 |
+
|
| 83 |
+
// Update the nodes...
|
| 84 |
+
var node = svg2.selectAll('g.node')
|
| 85 |
+
.data(nodes, function(d) {return d.id || (d.id = ++i); });
|
| 86 |
+
|
| 87 |
+
// Enter any new modes at the parent's previous position.
|
| 88 |
+
var nodeEnter = node.enter().append('g')
|
| 89 |
+
.attr('class', 'node')
|
| 90 |
+
.attr("transform", function(d) {
|
| 91 |
+
return "translate(" + source.y0 + "," + source.x0 + ")";
|
| 92 |
+
})
|
| 93 |
+
.on('click', click);
|
| 94 |
+
|
| 95 |
+
// Add Circle for the nodes
|
| 96 |
+
nodeEnter.append('circle')
|
| 97 |
+
.attr('class', 'node')
|
| 98 |
+
.attr('r', 1e-6)
|
| 99 |
+
.style("fill", function(d) {
|
| 100 |
+
if(d.name == "Non-performance"){
|
| 101 |
+
return d._children ? "red" : "#fff";
|
| 102 |
+
}else{
|
| 103 |
+
return d._children ? "blue" : "#fff";
|
| 104 |
+
}
|
| 105 |
+
});
|
| 106 |
+
|
| 107 |
+
// Add labels for the nodes
|
| 108 |
+
nodeEnter.append('text')
|
| 109 |
+
.attr("dy", ".40em")
|
| 110 |
+
.attr("x", function(d) {
|
| 111 |
+
return d.children || d._children ? -13 : 13;
|
| 112 |
+
})
|
| 113 |
+
.attr("text-anchor", function(d) {
|
| 114 |
+
return d.children || d._children ? "end" : "start";
|
| 115 |
+
})
|
| 116 |
+
.text(function(d) { return d.data.name; });
|
| 117 |
+
|
| 118 |
+
// UPDATE
|
| 119 |
+
var nodeUpdate = nodeEnter.merge(node);
|
| 120 |
+
|
| 121 |
+
// Transition to the proper position for the node
|
| 122 |
+
nodeUpdate.transition()
|
| 123 |
+
.duration(duration)
|
| 124 |
+
.attr("transform", function(d) {
|
| 125 |
+
return "translate(" + d.y + "," + d.x + ")";
|
| 126 |
+
});
|
| 127 |
+
|
| 128 |
+
// Update the node attributes and style
|
| 129 |
+
nodeUpdate.select('circle.node')
|
| 130 |
+
.attr('r', 8)
|
| 131 |
+
.style("fill", function(d) {
|
| 132 |
+
if(d.name == "Non-performance"){
|
| 133 |
+
return d._children ? "red" : "#fff";
|
| 134 |
+
}else{
|
| 135 |
+
return d._children ? "blue" : "#fff";
|
| 136 |
+
}
|
| 137 |
+
})
|
| 138 |
+
.attr('cursor', 'pointer');
|
| 139 |
+
|
| 140 |
+
|
| 141 |
+
// Remove any exiting nodes
|
| 142 |
+
var nodeExit = node.exit().transition()
|
| 143 |
+
.duration(duration)
|
| 144 |
+
.attr("transform", function(d) {
|
| 145 |
+
return "translate(" + source.y + "," + source.x + ")";
|
| 146 |
+
})
|
| 147 |
+
.remove();
|
| 148 |
+
|
| 149 |
+
// On exit reduce the node circles size to 0
|
| 150 |
+
nodeExit.select('circle')
|
| 151 |
+
.attr('r', 1e-6);
|
| 152 |
+
|
| 153 |
+
// On exit reduce the opacity of text labels
|
| 154 |
+
nodeExit.select('text')
|
| 155 |
+
.style('fill-opacity', 1e-6);
|
| 156 |
+
|
| 157 |
+
// ****************** links section ***************************
|
| 158 |
+
|
| 159 |
+
// Update the links...
|
| 160 |
+
var link = svg2.selectAll('path.link')
|
| 161 |
+
.data(links, function(d) { return d.id; });
|
| 162 |
+
|
| 163 |
+
// Enter any new links at the parent's previous position.
|
| 164 |
+
var linkEnter = link.enter().insert('path', "g")
|
| 165 |
+
.attr("class", "link")
|
| 166 |
+
.attr('d', function(d){
|
| 167 |
+
var o = {x: source.x0, y: source.y0}
|
| 168 |
+
return diagonal(o, o)
|
| 169 |
+
});
|
| 170 |
+
|
| 171 |
+
// UPDATE
|
| 172 |
+
var linkUpdate = linkEnter.merge(link);
|
| 173 |
+
|
| 174 |
+
// Transition back to the parent element position
|
| 175 |
+
linkUpdate.transition()
|
| 176 |
+
.duration(duration)
|
| 177 |
+
.attr('d', function(d){ return diagonal(d, d.parent) });
|
| 178 |
+
|
| 179 |
+
// Remove any exiting links
|
| 180 |
+
var linkExit = link.exit().transition()
|
| 181 |
+
.duration(duration)
|
| 182 |
+
.attr('d', function(d) {
|
| 183 |
+
var o = {x: source.x, y: source.y}
|
| 184 |
+
return diagonal(o, o)
|
| 185 |
+
})
|
| 186 |
+
.remove();
|
| 187 |
+
|
| 188 |
+
// Store the old positions for transition.
|
| 189 |
+
nodes.forEach(function(d){
|
| 190 |
+
d.x0 = d.x;
|
| 191 |
+
d.y0 = d.y;
|
| 192 |
+
});
|
| 193 |
+
|
| 194 |
+
// Creates a curved (diagonal) path from parent to the child nodes
|
| 195 |
+
function diagonal(s, d) {
|
| 196 |
+
|
| 197 |
+
path = `M ${s.y} ${s.x}
|
| 198 |
+
C ${(s.y + d.y) / 2} ${s.x},
|
| 199 |
+
${(s.y + d.y) / 2} ${d.x},
|
| 200 |
+
${d.y} ${d.x}`
|
| 201 |
+
|
| 202 |
+
return path
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
+
// Toggle children on click.
|
| 206 |
+
function click(d) {
|
| 207 |
+
if (d.children) {
|
| 208 |
+
d._children = d.children;
|
| 209 |
+
d.children = null;
|
| 210 |
+
} else {
|
| 211 |
+
d.children = d._children;
|
| 212 |
+
d._children = null;
|
| 213 |
+
}
|
| 214 |
+
update(d);
|
| 215 |
+
}
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
+
</script>
|
| 219 |
+
</div>
|
| 220 |
+
<div class = "graph">
|
| 221 |
+
|
| 222 |
+
<script src="//d3js.org/d3.v3.min.js"></script>
|
| 223 |
+
<script src="http://d3js.org/d3-selection-multi.v1.js"></script>
|
| 224 |
+
<script>
|
| 225 |
+
|
| 226 |
+
var links = [
|
| 227 |
+
{source: "Non Performance", target: "Customers", type: "49"},
|
| 228 |
+
{source: "Non Performance", target: "Investors", type: "54"},
|
| 229 |
+
{source: "Non Performance", target: "Society", type: "49"},
|
| 230 |
+
{source: "Non Performance", target: "Employee", type: "51"},
|
| 231 |
+
{source: "Employee", target: "Investors", type: "5"},
|
| 232 |
+
{source: "Employee", target: "Non Performance", type: "167"},
|
| 233 |
+
{source: "Employee", target: "Society", type: "0"},
|
| 234 |
+
{source: "Employee", target: "Customers", type: "0"},
|
| 235 |
+
// {source: "Employee", target: "Employee", type: "2"},
|
| 236 |
+
{source: "Investors", target: "Employee", type: "3"},
|
| 237 |
+
{source: "Investors", target: "Society", type: "1"},
|
| 238 |
+
{source: "Investors", target: "Customers", type: "1"},
|
| 239 |
+
{source: "Investors", target: "Non Performance", type: "168"},
|
| 240 |
+
{source: "Society", target: "Investors", type: "5"},
|
| 241 |
+
{source: "Society", target: "Employee", type: "2"},
|
| 242 |
+
{source: "Society", target: "Customers", type: "0"},
|
| 243 |
+
{source: "Society", target: "Non Performance", type: "167"},
|
| 244 |
+
{source: "Customers", target: "Investors", type: "0"},
|
| 245 |
+
{source: "Customers", target: "Employee", type: "2"},
|
| 246 |
+
{source: "Customers", target: "Society", type: "0"},
|
| 247 |
+
{source: "Customers", target: "Non Performance", type: "167"},
|
| 248 |
+
//{source: "Investors", target: "Investors", type: "6"},
|
| 249 |
+
// {source: "Customers", target: "Customers", type: "0"},
|
| 250 |
+
//{source: "Society", target: "Society", type: "0"},
|
| 251 |
+
//{source: "Non Performance", target: "Non Performance", type: "216"}
|
| 252 |
+
|
| 253 |
+
|
| 254 |
+
];
|
| 255 |
+
|
| 256 |
+
|
| 257 |
+
// Compute the distinct nodes from the links.
|
| 258 |
+
links.sort(function(a,b) {
|
| 259 |
+
if (a.source > b.source) {return 1;}
|
| 260 |
+
else if (a.source < b.source) {return -1;}
|
| 261 |
+
else {
|
| 262 |
+
if (a.target > b.target) {return 1;}
|
| 263 |
+
if (a.target < b.target) {return -1;}
|
| 264 |
+
else {return 0;}
|
| 265 |
+
}
|
| 266 |
+
});
|
| 267 |
+
//any links with duplicate source and target get an incremented 'linknum'
|
| 268 |
+
for (var i=0; i<links.length; i++) {
|
| 269 |
+
if (i != 0 &&
|
| 270 |
+
links[i].source == links[i-1].source &&
|
| 271 |
+
links[i].target == links[i-1].target) {
|
| 272 |
+
links[i].linknum = links[i-1].linknum + 1;
|
| 273 |
+
}
|
| 274 |
+
else {links[i].linknum = 1;};
|
| 275 |
+
};
|
| 276 |
+
|
| 277 |
+
var nodes = {};
|
| 278 |
+
|
| 279 |
+
// Compute the distinct nodes from the links.
|
| 280 |
+
links.forEach(function(link) {
|
| 281 |
+
link.source = nodes[link.source] || (nodes[link.source] = {name: link.source});
|
| 282 |
+
link.target = nodes[link.target] || (nodes[link.target] = {name: link.target});
|
| 283 |
+
});
|
| 284 |
+
|
| 285 |
+
var width = 550,
|
| 286 |
+
height = 850;
|
| 287 |
+
|
| 288 |
+
|
| 289 |
+
|
| 290 |
+
var force = d3.layout.force()
|
| 291 |
+
.nodes(d3.values(nodes))
|
| 292 |
+
.links(links)
|
| 293 |
+
.size([width, height])
|
| 294 |
+
.linkDistance(400)
|
| 295 |
+
.charge(-3000)
|
| 296 |
+
.on("tick", tick)
|
| 297 |
+
.start();
|
| 298 |
+
|
| 299 |
+
var svg = d3.select("body").append("svg")
|
| 300 |
+
.attr("width", width)
|
| 301 |
+
.attr("height", height)
|
| 302 |
+
.call(d3.behavior.zoom().on("zoom", function () {
|
| 303 |
+
svg.attr("transform", "translate(" + d3.event.translate + ")" + " scale(" + d3.event.scale + ")")
|
| 304 |
+
}))
|
| 305 |
+
.append("g");
|
| 306 |
+
|
| 307 |
+
|
| 308 |
+
|
| 309 |
+
|
| 310 |
+
|
| 311 |
+
svg.append("svg:defs").selectAll("marker")
|
| 312 |
+
.data(["49", "54", "49","51","5","167", "0", "0", "2","3","1","1","168","5","2","0","167","0","2","0","167","2","6","0","0","216"])
|
| 313 |
+
.enter().append("svg:marker")
|
| 314 |
+
.attr("id", String)
|
| 315 |
+
.attr("viewBox", "0 -5 10 10")
|
| 316 |
+
.attr("refX", 24)
|
| 317 |
+
.attr("refY", -1.8)
|
| 318 |
+
.attr("markerWidth", 6)
|
| 319 |
+
.attr("markerHeight", 6)
|
| 320 |
+
.attr("orient", "auto")
|
| 321 |
+
.append("svg:path")
|
| 322 |
+
.attr("d", "M0,-5L10,0L0,5");
|
| 323 |
+
|
| 324 |
+
|
| 325 |
+
// Per-type markers, as they don't inherit styles.
|
| 326 |
+
var path = svg.append("svg:g").selectAll("path")
|
| 327 |
+
.data(force.links())
|
| 328 |
+
.enter().append("svg:path")
|
| 329 |
+
|
| 330 |
+
.attr("class", function(d) { return "link " + d.type; })
|
| 331 |
+
.attr("id",function(d,i) { return "linkId_" + i; })
|
| 332 |
+
.attr("marker-end", function(d) { return "url(#" + d.type + ")"; });
|
| 333 |
+
|
| 334 |
+
// var node = svg.append("g").selectAll("node")
|
| 335 |
+
// .data(force.nodes())
|
| 336 |
+
// .enter().append("circle")
|
| 337 |
+
// .attr("r", 10)
|
| 338 |
+
// .call(force.drag);
|
| 339 |
+
|
| 340 |
+
var selflink = svg.append("svg:g").selectAll(".selflink")
|
| 341 |
+
.data(force.links())
|
| 342 |
+
.enter().append("path")
|
| 343 |
+
.attr("class","link")
|
| 344 |
+
.attr("class", function(d) { return "link " + d.type; })
|
| 345 |
+
.attr("id",function(d,i) { return "linkId_" + i; })
|
| 346 |
+
.attr("marker-end", function(d) { return "url(#" + d.type + ")"; });
|
| 347 |
+
|
| 348 |
+
var node = svg.selectAll(".node")
|
| 349 |
+
.data(force.nodes())
|
| 350 |
+
.enter().append("g")
|
| 351 |
+
.attr("class", "node")
|
| 352 |
+
.on("click", click)
|
| 353 |
+
.on("dblclick", dblclick)
|
| 354 |
+
.on("mouseover", mouseover)
|
| 355 |
+
.on("mouseout", mouseout)
|
| 356 |
+
.on("mouseenter", (evt, d) => {
|
| 357 |
+
path
|
| 358 |
+
.attr("display", "none")
|
| 359 |
+
.filter(l => l.source.type === d.type || l.target.type === d.type)
|
| 360 |
+
.attr("display", "block");
|
| 361 |
+
})
|
| 362 |
+
.on("mouseleave", evt => {
|
| 363 |
+
path.attr("display", "block");
|
| 364 |
+
})
|
| 365 |
+
.call(force.drag);
|
| 366 |
+
|
| 367 |
+
|
| 368 |
+
// add the nodes
|
| 369 |
+
node.append("circle")
|
| 370 |
+
.attr("r", 13)
|
| 371 |
+
.style("fill", function(d){
|
| 372 |
+
if(d.name == "Non Performance"){
|
| 373 |
+
return "red";
|
| 374 |
+
}else{
|
| 375 |
+
return "blue";
|
| 376 |
+
}
|
| 377 |
+
})
|
| 378 |
+
.style("stroke", "black")
|
| 379 |
+
|
| 380 |
+
|
| 381 |
+
|
| 382 |
+
var text = svg.append("g").selectAll("text")
|
| 383 |
+
.data(force.nodes())
|
| 384 |
+
.enter().append("text")
|
| 385 |
+
.attr("x", 8)
|
| 386 |
+
.attr("y", ".31em")
|
| 387 |
+
.text(function(d) { return d.name; });
|
| 388 |
+
var linktext = svg.append("svg:g").selectAll("g.linklabelholder").data(force.links());
|
| 389 |
+
|
| 390 |
+
linktext.enter().append("g").attr("class", "linklabelholder")
|
| 391 |
+
.append("text")
|
| 392 |
+
.attr("class", "linklabel")
|
| 393 |
+
.style("font-size", "13px")
|
| 394 |
+
.attr("x", "50")
|
| 395 |
+
.attr("y", "-20")
|
| 396 |
+
.attr("text-anchor", "start")
|
| 397 |
+
.style("fill","#000")
|
| 398 |
+
.append("textPath")
|
| 399 |
+
.attr("xlink:href",function(d,i) { return "#linkId_" + i;})
|
| 400 |
+
.text(function(d) {
|
| 401 |
+
return d.type;
|
| 402 |
+
});
|
| 403 |
+
|
| 404 |
+
|
| 405 |
+
// Use elliptical arc path segments to doubly-encode directionality.
|
| 406 |
+
function tick() {
|
| 407 |
+
path.attr("d", linkArc);
|
| 408 |
+
// node.attr("transform", transform);
|
| 409 |
+
text.attr("transform", transform);
|
| 410 |
+
node
|
| 411 |
+
.attr("transform", function(d) {
|
| 412 |
+
return "translate(" + d.x + "," + d.y + ")"; })
|
| 413 |
+
|
| 414 |
+
|
| 415 |
+
selflink.attr("d", function(d) {
|
| 416 |
+
var x1 = d.source.x,
|
| 417 |
+
y1 = d.source.y,
|
| 418 |
+
x2 = d.target.x,
|
| 419 |
+
y2 = d.target.y,
|
| 420 |
+
dx = x2 - x1,
|
| 421 |
+
dy = y2 - y1,
|
| 422 |
+
dr = Math.sqrt(dx * dx + dy * dy),
|
| 423 |
+
|
| 424 |
+
// Defaults for normal edge.
|
| 425 |
+
drx = dr,
|
| 426 |
+
dry = dr,
|
| 427 |
+
xRotation = 5, // degrees
|
| 428 |
+
largeArc = 0, // 1 or 0
|
| 429 |
+
sweep = 1; // 1 or 0
|
| 430 |
+
|
| 431 |
+
// Self edge.
|
| 432 |
+
if ( x1 === x2 && y1 === y2 ) {
|
| 433 |
+
// Fiddle with this angle to get loop oriented.
|
| 434 |
+
xRotation = -70;
|
| 435 |
+
|
| 436 |
+
// Needs to be 1.
|
| 437 |
+
largeArc = 1;
|
| 438 |
+
|
| 439 |
+
// Change sweep to change orientation of loop.
|
| 440 |
+
//sweep = 0;
|
| 441 |
+
|
| 442 |
+
// Make drx and dry different to get an ellipse
|
| 443 |
+
// instead of a circle.
|
| 444 |
+
drx = 30;
|
| 445 |
+
dry = 15;
|
| 446 |
+
|
| 447 |
+
// For whatever reason the arc collapses to a point if the beginning
|
| 448 |
+
// and ending points of the arc are the same, so kludge it.
|
| 449 |
+
x2 = x2 + 1;
|
| 450 |
+
y2 = y2 + 1;
|
| 451 |
+
}
|
| 452 |
+
|
| 453 |
+
return "M" + x1 + "," + y1 + "A" + drx + "," + dry + " " + xRotation + "," + largeArc + "," + sweep + " " + x2 + "," + y2;
|
| 454 |
+
});
|
| 455 |
+
}
|
| 456 |
+
|
| 457 |
+
function linkArc(d) {
|
| 458 |
+
var dx = d.target.x - d.source.x,
|
| 459 |
+
dy = d.target.y - d.source.y,
|
| 460 |
+
dr = Math.sqrt(dx * dx + dy * dy);
|
| 461 |
+
return "M" + d.source.x + "," + d.source.y + "A" + dr + "," + dr + " 0 0,1 " + d.target.x + "," + d.target.y;
|
| 462 |
+
}
|
| 463 |
+
|
| 464 |
+
function transform(d) {
|
| 465 |
+
return "translate(" + d.x + "," + d.y + ")";
|
| 466 |
+
}
|
| 467 |
+
function click() {
|
| 468 |
+
d3.select(this).select("text").transition()
|
| 469 |
+
.duration(750)
|
| 470 |
+
.attr("x", 22)
|
| 471 |
+
.style("fill", "steelblue")
|
| 472 |
+
.style("stroke", "lightsteelblue")
|
| 473 |
+
.style("stroke-width", ".5px")
|
| 474 |
+
.style("font", "20px sans-serif");
|
| 475 |
+
d3.select(this).select("circle").transition()
|
| 476 |
+
.duration(750)
|
| 477 |
+
.attr("r", 16)
|
| 478 |
+
.style("fill", "lightsteelblue");
|
| 479 |
+
}
|
| 480 |
+
|
| 481 |
+
// action to take on mouse double click
|
| 482 |
+
function dblclick() {
|
| 483 |
+
d3.select(this).select("circle").transition()
|
| 484 |
+
.duration(750)
|
| 485 |
+
.attr("r", 6)
|
| 486 |
+
.style("fill", "#ccc");
|
| 487 |
+
d3.select(this).select("text").transition()
|
| 488 |
+
.duration(750)
|
| 489 |
+
.attr("x", 12)
|
| 490 |
+
.style("stroke", "none")
|
| 491 |
+
.style("fill", "black")
|
| 492 |
+
.style("stroke", "none")
|
| 493 |
+
.style("font", "10px sans-serif");
|
| 494 |
+
}
|
| 495 |
+
|
| 496 |
+
function mouseover() {
|
| 497 |
+
d3.select(this).select("circle").transition()
|
| 498 |
+
.duration(750)
|
| 499 |
+
.attr("r", 25)
|
| 500 |
+
.style("stroke-opacity", 1.0);
|
| 501 |
+
|
| 502 |
+
}
|
| 503 |
+
|
| 504 |
+
function mouseout() {
|
| 505 |
+
d3.select(this).select("circle").transition()
|
| 506 |
+
.duration(750)
|
| 507 |
+
.attr("r", 15);
|
| 508 |
+
}
|
| 509 |
+
|
| 510 |
+
|
| 511 |
+
|
| 512 |
+
function dragstarted(d) {
|
| 513 |
+
if (!d3.event.active) simulation.alphaTarget(0.8).restart()
|
| 514 |
+
d.fx = d.x;
|
| 515 |
+
d.fy = d.y;
|
| 516 |
+
}
|
| 517 |
+
|
| 518 |
+
function dragged(d) {
|
| 519 |
+
d.fx = d3.event.x;
|
| 520 |
+
d.fy = d3.event.y;
|
| 521 |
+
}
|
| 522 |
+
|
| 523 |
+
|
| 524 |
+
|
| 525 |
+
|
| 526 |
+
|
| 527 |
+
|
| 528 |
+
|
| 529 |
+
|
| 530 |
+
|
| 531 |
+
|
| 532 |
+
|
| 533 |
+
|
| 534 |
+
|
| 535 |
+
|
| 536 |
+
|
| 537 |
+
</script>
|
| 538 |
+
</div>
|
| 539 |
+
</div>
|
| 540 |
+
</body>
|
div.css
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
path.link {
|
| 2 |
+
fill: none;
|
| 3 |
+
stroke: #666;
|
| 4 |
+
stroke-width: 1.5px;
|
| 5 |
+
}
|
| 6 |
+
|
| 7 |
+
path.link:hover {stroke: red;stroke-width: 4px}
|
| 8 |
+
|
| 9 |
+
path.link.licensing {
|
| 10 |
+
stroke: green;
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
path.link.resolved {
|
| 14 |
+
stroke-dasharray: 0,2 1;
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
circle {
|
| 18 |
+
fill: #ccc;
|
| 19 |
+
stroke: #333;
|
| 20 |
+
stroke-width: 1.5px;
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
text {
|
| 24 |
+
font: 10px sans-serif;
|
| 25 |
+
pointer-events: none;
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
text.shadow {
|
| 29 |
+
stroke: #fff;
|
| 30 |
+
stroke-width: 3px;
|
| 31 |
+
stroke-opacity: .8;
|
| 32 |
+
}
|
side.css
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*.tree*/
|
| 2 |
+
/*{*/
|
| 3 |
+
/* position: absolute;*/
|
| 4 |
+
/* top: 50%;*/
|
| 5 |
+
/* left: 50%;*/
|
| 6 |
+
/* transform: translate(-50%, -50%);*/
|
| 7 |
+
/* background-color : #4444aa;*/
|
| 8 |
+
/*}*/
|
| 9 |
+
/*.graph*/
|
| 10 |
+
/*{*/
|
| 11 |
+
/* position: absolute;*/
|
| 12 |
+
/* top: 50%;*/
|
| 13 |
+
/* right: 50%;*/
|
| 14 |
+
/* transform: translate(50%, 50%);*/
|
| 15 |
+
/*}*/
|
| 16 |
+
|
| 17 |
+
.container{
|
| 18 |
+
display: flex;
|
| 19 |
+
flex-direction: row;
|
| 20 |
+
width: 100vw;
|
| 21 |
+
}
|
tree.css
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.node circle {
|
| 2 |
+
fill: #fff;
|
| 3 |
+
stroke: black;
|
| 4 |
+
stroke-width: 2px;
|
| 5 |
+
}
|
| 6 |
+
|
| 7 |
+
.node text {
|
| 8 |
+
font: 12px sans-serif;
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
.link {
|
| 12 |
+
fill: none;
|
| 13 |
+
stroke: #ccc;
|
| 14 |
+
stroke-width: 2px;
|
| 15 |
+
}
|