Spaces:
Running
Running
Upload 3 files
Browse files- controller.py +19 -0
- taxonomy.json +194 -0
- templates/index.html +172 -0
controller.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from flask import Flask, render_template
|
| 2 |
+
from flask import send_file
|
| 3 |
+
|
| 4 |
+
app = Flask(__name__)
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
@app.route("/")
|
| 8 |
+
def index():
|
| 9 |
+
return render_template("index.html")
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
@app.route("/taxonomy.json")
|
| 13 |
+
def loadFile():
|
| 14 |
+
path = "taxonomy.json"
|
| 15 |
+
return send_file(path, as_attachment=True)
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
if __name__ == "__main__":
|
| 19 |
+
app.run()
|
taxonomy.json
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "ORKG-taxonomy",
|
| 3 |
+
"children": [
|
| 4 |
+
{
|
| 5 |
+
"name": "Physical Sciences and Mathematics",
|
| 6 |
+
"children": [
|
| 7 |
+
{ "name": "Physics",
|
| 8 |
+
"children": [
|
| 9 |
+
{ "name": "Quantum Physics" },
|
| 10 |
+
{ "name": "Nonlinear Sciences" },
|
| 11 |
+
{ "name": "Atomic, Molecular and Optical Physics" },
|
| 12 |
+
{ "name": "Condensed Matter Physics" },
|
| 13 |
+
{ "name": "Optics" },
|
| 14 |
+
{ "name": "Fluid Dynamics" },
|
| 15 |
+
{ "name": "Plasma and Beam Physics" },
|
| 16 |
+
{ "name": "Biological and Chemical Physics" },
|
| 17 |
+
{ "name": "Computational Physics" },
|
| 18 |
+
{ "name": "Medical Physics" },
|
| 19 |
+
{ "name": "Physics Education" },
|
| 20 |
+
{ "name": "History and Philosophy of Physics" },
|
| 21 |
+
{ "name": "Data Analysis, Statistics and Probability" },
|
| 22 |
+
{ "name": "Space Physics" },
|
| 23 |
+
{ "name": "Popular Physics" }
|
| 24 |
+
]},
|
| 25 |
+
{ "name": "Cosmology, Relativity, and Gravity" },
|
| 26 |
+
{ "name": "Astrophysics and Astronomy",
|
| 27 |
+
"children": [
|
| 28 |
+
{ "name": "The Sun and the Solar System" },
|
| 29 |
+
{ "name": "External Galaxies" },
|
| 30 |
+
{ "name": "Cosmology" },
|
| 31 |
+
{ "name": "Physical Processes" },
|
| 32 |
+
{ "name": "Instrumentation" }
|
| 33 |
+
]},
|
| 34 |
+
{ "name": "Mathematics",
|
| 35 |
+
"children": [
|
| 36 |
+
{ "name": "Dynamics/Dynamical Systems" },
|
| 37 |
+
{ "name": "Geometry and Topology" },
|
| 38 |
+
{ "name": "Discrete Mathematics and Combinatorics" },
|
| 39 |
+
{ "name": "Analysis" },
|
| 40 |
+
{ "name": "Number Theory" },
|
| 41 |
+
{ "name": "Algebraic Geometry" },
|
| 42 |
+
{ "name": "Algebra" },
|
| 43 |
+
{ "name": "Set Theory" },
|
| 44 |
+
{ "name": "Logic and Foundations" },
|
| 45 |
+
{ "name": "Complex Variables" },
|
| 46 |
+
{ "name": "Category Theory" },
|
| 47 |
+
{ "name": "Mathematics History and Overview" },
|
| 48 |
+
{ "name": "Mathematical Software" }
|
| 49 |
+
]},
|
| 50 |
+
{ "name": "Computer Sciences",
|
| 51 |
+
"children": [
|
| 52 |
+
{ "name": "Computer Vision and Pattern Recognition" },
|
| 53 |
+
{ "name": "Artificial Intelligence",
|
| 54 |
+
"children": [
|
| 55 |
+
{ "name": "Machine Learning" },
|
| 56 |
+
{ "name": "Image and Video Processing" },
|
| 57 |
+
{ "name": "Multiagent Systems" },
|
| 58 |
+
{ "name": "Audio and Speech Processing" }
|
| 59 |
+
] },
|
| 60 |
+
{ "name": "Theory/Algorithms",
|
| 61 |
+
"children": [
|
| 62 |
+
{ "name": "Computational Geometry"}
|
| 63 |
+
]},
|
| 64 |
+
{ "name": "Software Engineering" },
|
| 65 |
+
{ "name": "Cryptography and Security" },
|
| 66 |
+
{ "name": "Databases/Information Systems",
|
| 67 |
+
"children": [
|
| 68 |
+
{ "name": "Digital Libraries" }
|
| 69 |
+
] },
|
| 70 |
+
{ "name": "Human Computer Interfaces" },
|
| 71 |
+
{ "name": "Programming Languages/Compilers" },
|
| 72 |
+
{ "name": "Computers and Society" },
|
| 73 |
+
{ "name": "Information Systems, Process and Knowledge Management" },
|
| 74 |
+
{ "name": "Computer Science and Game Theory" },
|
| 75 |
+
{ "name": "Security and Dependability" },
|
| 76 |
+
{ "name": "Graphics" },
|
| 77 |
+
{ "name": "OS/Networks" }
|
| 78 |
+
]},
|
| 79 |
+
{ "name": "Statistics and Probability",
|
| 80 |
+
"children": [
|
| 81 |
+
{ "name": "Statistical Methodology" },
|
| 82 |
+
{ "name": "Applied Statistics" }
|
| 83 |
+
] },
|
| 84 |
+
{ "name": "Applied Mathematics",
|
| 85 |
+
"children": [
|
| 86 |
+
{ "name": "Numerical Analysis and Computation" }
|
| 87 |
+
] },
|
| 88 |
+
{ "name": "Chemistry" },
|
| 89 |
+
{ "name": "Earth Sciences",
|
| 90 |
+
"children": [
|
| 91 |
+
{ "name": "Environmental Sciences" },
|
| 92 |
+
{ "name": "Geophysics and Seismology" }
|
| 93 |
+
] },
|
| 94 |
+
{ "name": "Oceanography and Atmospheric Sciences and Meteorology",
|
| 95 |
+
"children": [
|
| 96 |
+
{ "name": "Oceanography" },
|
| 97 |
+
{ "name": "Atmospheric Sciences" }
|
| 98 |
+
]}
|
| 99 |
+
]
|
| 100 |
+
},
|
| 101 |
+
{
|
| 102 |
+
"name": "Engineering",
|
| 103 |
+
"children": [
|
| 104 |
+
{"name": "Information Science"},
|
| 105 |
+
{"name": "Operations Research, Systems Engineering and Industrial Engineering"},
|
| 106 |
+
{"name": "Electrical and Computer Engineering",
|
| 107 |
+
"children": [
|
| 108 |
+
{"name": "Signal Processing"},
|
| 109 |
+
{"name": "Controls and Control Theory"}
|
| 110 |
+
]},
|
| 111 |
+
{"name": "Computational Engineering"},
|
| 112 |
+
{"name": "Nanoscience and Nanotechnology"},
|
| 113 |
+
{"name": "Mechanical Engineering",
|
| 114 |
+
"children": [
|
| 115 |
+
{"name": "Energy Systems"}
|
| 116 |
+
]},
|
| 117 |
+
{"name": "Civil and Environmental Engineering"},
|
| 118 |
+
{"name": "Biomedical Engineering and Bioengineering",
|
| 119 |
+
"children": [
|
| 120 |
+
{"name": "Molecular, cellular, and tissue engineering",
|
| 121 |
+
"children": [
|
| 122 |
+
{"name": "Tissues and Organs"}
|
| 123 |
+
]}
|
| 124 |
+
]}
|
| 125 |
+
]
|
| 126 |
+
},
|
| 127 |
+
{
|
| 128 |
+
"name": "Life Sciences",
|
| 129 |
+
"children": [
|
| 130 |
+
{ "name": "Bioinformatics" },
|
| 131 |
+
{ "name": "Ecology and Evolutionary Biology",
|
| 132 |
+
"children": [
|
| 133 |
+
{ "name": "Population Biology" }
|
| 134 |
+
]},
|
| 135 |
+
{ "name": "Microbiology" },
|
| 136 |
+
{ "name": "Nursing Pharmacology, Toxicology and Environmental Health",
|
| 137 |
+
"children" : [
|
| 138 |
+
{ "name": "Toxicology" },
|
| 139 |
+
{ "name": "Medicinal Chemistry and Pharmaceutics" }
|
| 140 |
+
]},
|
| 141 |
+
{ "name": "Animal Sciences" },
|
| 142 |
+
{ "name": "Medicine" },
|
| 143 |
+
{ "name": "Biology/Integrated Biology/ Integrated Biomedical Sciences",
|
| 144 |
+
"children": [
|
| 145 |
+
{ "name": "Motor Control" },
|
| 146 |
+
{ "name": "Quantitative Methods" }
|
| 147 |
+
]},
|
| 148 |
+
{ "name": "Biochemistry, Biophysics, and Structural Biology",
|
| 149 |
+
"children": [
|
| 150 |
+
{ "name": "Molecular Biology"}
|
| 151 |
+
]},
|
| 152 |
+
{ "name": "Neuroscience and Neurobiology" },
|
| 153 |
+
{ "name": "Public Health" },
|
| 154 |
+
{ "name": "Genetics and Genomics",
|
| 155 |
+
"children" : [
|
| 156 |
+
{ "name": "Genomics"}
|
| 157 |
+
]},
|
| 158 |
+
{ "name": "Cell and Developmental Biology",
|
| 159 |
+
"children": [
|
| 160 |
+
{ "name": "Cell Behavior"}
|
| 161 |
+
]}
|
| 162 |
+
]
|
| 163 |
+
},
|
| 164 |
+
{
|
| 165 |
+
"name": "Social and Behavioral Sciences",
|
| 166 |
+
"children": [
|
| 167 |
+
{ "name": "Linguistics",
|
| 168 |
+
"children": [
|
| 169 |
+
{ "name": "Computational Linguistics" }
|
| 170 |
+
] },
|
| 171 |
+
{ "name": "Public Affairs, Public Policy and Public Administration" },
|
| 172 |
+
{ "name": "Economics",
|
| 173 |
+
"children": [
|
| 174 |
+
{ "name": "Quantitative Finance" },
|
| 175 |
+
{ "name": "Econometrics" },
|
| 176 |
+
{ "name": "Economic Theory" }
|
| 177 |
+
] },
|
| 178 |
+
{ "name": "Sociology",
|
| 179 |
+
"children": [
|
| 180 |
+
{ "name": "Physics and Society" }
|
| 181 |
+
] },
|
| 182 |
+
{ "name": "Communication Sciences",
|
| 183 |
+
"children": [
|
| 184 |
+
{ "name": "Communication Technology and New Media" }
|
| 185 |
+
] },
|
| 186 |
+
{ "name": "Science and Technology Studies" },
|
| 187 |
+
{ "name": "Psychology" }
|
| 188 |
+
]
|
| 189 |
+
},
|
| 190 |
+
{
|
| 191 |
+
"name": "Arts and Humanities"
|
| 192 |
+
}
|
| 193 |
+
]
|
| 194 |
+
}
|
templates/index.html
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<meta charset="utf-8">
|
| 3 |
+
<style>
|
| 4 |
+
|
| 5 |
+
.node {
|
| 6 |
+
cursor: pointer;
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
.node circle {
|
| 10 |
+
fill: #fff;
|
| 11 |
+
stroke: steelblue;
|
| 12 |
+
stroke-width: 2.0px;
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
.node text {
|
| 16 |
+
font: 20px sans-serif;
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
.link {
|
| 20 |
+
fill: none;
|
| 21 |
+
stroke: #ccc;
|
| 22 |
+
stroke-width: 2.0px;
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
</style>
|
| 26 |
+
<body>
|
| 27 |
+
<!--<script src="https://cdnjs.cloudtaxonomy.com/ajax/libs/d3/3.4.5/d3.min.js" integrity="sha512-ixqLAANjnCFERy/YNIycwzbDuk3tEWaVOwepwCh65GKbt+GgnCV/dO1ne+OZXwif8q/j79PKb8RGdNu27055HA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>-->
|
| 28 |
+
<!--<script src="//d3js.org/d3.v3.min.js"></script>-->
|
| 29 |
+
<script src="https://d3js.org/d3.v3.min.js"></script>
|
| 30 |
+
<script>
|
| 31 |
+
|
| 32 |
+
var margin = {top: 20, right: 900, bottom: 20, left: 200},
|
| 33 |
+
width = 960 - margin.right - margin.left,
|
| 34 |
+
height = 800 - margin.top - margin.bottom;
|
| 35 |
+
|
| 36 |
+
var i = 0,
|
| 37 |
+
duration = 750,
|
| 38 |
+
root;
|
| 39 |
+
|
| 40 |
+
var tree = d3.layout.tree()
|
| 41 |
+
.size([height, width]);
|
| 42 |
+
|
| 43 |
+
var diagonal = d3.svg.diagonal()
|
| 44 |
+
.projection(function(d) { return [d.y, d.x]; });
|
| 45 |
+
|
| 46 |
+
var svg = d3.select("body").append("svg")
|
| 47 |
+
.attr("width", 2000)
|
| 48 |
+
.attr("height", height + margin.top + margin.bottom)
|
| 49 |
+
.append("g")
|
| 50 |
+
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
|
| 51 |
+
|
| 52 |
+
d3.json("taxonomy.json", function(error, taxonomy) {
|
| 53 |
+
if (error) throw error;
|
| 54 |
+
|
| 55 |
+
root = taxonomy;
|
| 56 |
+
root.x0 = height / 2;
|
| 57 |
+
root.y0 = 0;
|
| 58 |
+
|
| 59 |
+
function collapse(d) {
|
| 60 |
+
if (d.children) {
|
| 61 |
+
d._children = d.children;
|
| 62 |
+
d._children.forEach(collapse);
|
| 63 |
+
d.children = null;
|
| 64 |
+
}
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
root.children.forEach(collapse);
|
| 68 |
+
update(root);
|
| 69 |
+
});
|
| 70 |
+
|
| 71 |
+
d3.select(self.frameElement).style("height", "800px");
|
| 72 |
+
|
| 73 |
+
function update(source) {
|
| 74 |
+
|
| 75 |
+
// Compute the new tree layout.
|
| 76 |
+
var nodes = tree.nodes(root).reverse(),
|
| 77 |
+
links = tree.links(nodes);
|
| 78 |
+
|
| 79 |
+
// Normalize for fixed-depth.
|
| 80 |
+
nodes.forEach(function(d) { d.y = d.depth * 180; });
|
| 81 |
+
|
| 82 |
+
// Update the nodes…
|
| 83 |
+
var node = svg.selectAll("g.node")
|
| 84 |
+
.data(nodes, function(d) { return d.id || (d.id = ++i); });
|
| 85 |
+
|
| 86 |
+
// Enter any new nodes at the parent's previous position.
|
| 87 |
+
var nodeEnter = node.enter().append("g")
|
| 88 |
+
.attr("class", "node")
|
| 89 |
+
.attr("transform", function(d) { return "translate(" + source.y0 + "," + source.x0 + ")"; })
|
| 90 |
+
.on("click", click);
|
| 91 |
+
|
| 92 |
+
nodeEnter.append("circle")
|
| 93 |
+
.attr("r", 1e-6)
|
| 94 |
+
.style("fill", function(d) { return d._children ? "lightsteelblue" : "#fff"; });
|
| 95 |
+
|
| 96 |
+
nodeEnter.append("text")
|
| 97 |
+
.attr("x", function(d) { return d.children || d._children ? -10 : 10; })
|
| 98 |
+
.attr("dy", ".35em")
|
| 99 |
+
.attr("text-anchor", function(d) { return d.children || d._children ? "end" : "start"; })
|
| 100 |
+
.text(function(d) { return d.name; })
|
| 101 |
+
.style("fill-opacity", 1e-6);
|
| 102 |
+
|
| 103 |
+
// Transition nodes to their new position.
|
| 104 |
+
var nodeUpdate = node.transition()
|
| 105 |
+
.duration(duration)
|
| 106 |
+
.attr("transform", function(d) { return "translate(" + d.y + "," + d.x + ")"; });
|
| 107 |
+
|
| 108 |
+
nodeUpdate.select("circle")
|
| 109 |
+
.attr("r", 4.5)
|
| 110 |
+
.style("fill", function(d) { return d._children ? "lightsteelblue" : "#fff"; });
|
| 111 |
+
|
| 112 |
+
nodeUpdate.select("text")
|
| 113 |
+
.style("fill-opacity", 1);
|
| 114 |
+
|
| 115 |
+
// Transition exiting nodes to the parent's new position.
|
| 116 |
+
var nodeExit = node.exit().transition()
|
| 117 |
+
.duration(duration)
|
| 118 |
+
.attr("transform", function(d) { return "translate(" + source.y + "," + source.x + ")"; })
|
| 119 |
+
.remove();
|
| 120 |
+
|
| 121 |
+
nodeExit.select("circle")
|
| 122 |
+
.attr("r", 1e-6);
|
| 123 |
+
|
| 124 |
+
nodeExit.select("text")
|
| 125 |
+
.style("fill-opacity", 1e-6);
|
| 126 |
+
|
| 127 |
+
// Update the links…
|
| 128 |
+
var link = svg.selectAll("path.link")
|
| 129 |
+
.data(links, function(d) { return d.target.id; });
|
| 130 |
+
|
| 131 |
+
// Enter any new links at the parent's previous position.
|
| 132 |
+
link.enter().insert("path", "g")
|
| 133 |
+
.attr("class", "link")
|
| 134 |
+
.attr("d", function(d) {
|
| 135 |
+
var o = {x: source.x0, y: source.y0};
|
| 136 |
+
return diagonal({source: o, target: o});
|
| 137 |
+
});
|
| 138 |
+
|
| 139 |
+
// Transition links to their new position.
|
| 140 |
+
link.transition()
|
| 141 |
+
.duration(duration)
|
| 142 |
+
.attr("d", diagonal);
|
| 143 |
+
|
| 144 |
+
// Transition exiting nodes to the parent's new position.
|
| 145 |
+
link.exit().transition()
|
| 146 |
+
.duration(duration)
|
| 147 |
+
.attr("d", function(d) {
|
| 148 |
+
var o = {x: source.x, y: source.y};
|
| 149 |
+
return diagonal({source: o, target: o});
|
| 150 |
+
})
|
| 151 |
+
.remove();
|
| 152 |
+
|
| 153 |
+
// Stash the old positions for transition.
|
| 154 |
+
nodes.forEach(function(d) {
|
| 155 |
+
d.x0 = d.x;
|
| 156 |
+
d.y0 = d.y;
|
| 157 |
+
});
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
// Toggle children on click.
|
| 161 |
+
function click(d) {
|
| 162 |
+
if (d.children) {
|
| 163 |
+
d._children = d.children;
|
| 164 |
+
d.children = null;
|
| 165 |
+
} else {
|
| 166 |
+
d.children = d._children;
|
| 167 |
+
d._children = null;
|
| 168 |
+
}
|
| 169 |
+
update(d);
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
</script>
|