Skip to content

Instantly share code, notes, and snippets.

@mro4354
Last active December 15, 2016 20:25
Show Gist options
  • Save mro4354/d2bfa19dae19e88a125632c0b292dabb to your computer and use it in GitHub Desktop.
Save mro4354/d2bfa19dae19e88a125632c0b292dabb to your computer and use it in GitHub Desktop.
NBA_Championship_Teams
{
"name": "NBA Champions",
"children": [
{
"name": "Atlanta Hawks",
"children": [
{
"name": "1958",
"children": [
{"name": "Bob Pettit", "size": 3938},
{"name": "Slater Martin", "size": 3812},
{"name": "Cliff Hagan", "size": 6714},
{"name": "Jack McMahon", "size": 743},
{"name": "Ed Macauley", "size": 744}
]
}
]
},
{
"name": "Boston Celtics",
"children": [
{
"name": "1957",
"children": [
{"name": "Bill Russell", "size": 3938},
{"name": "Bob Cousy", "size": 3812},
{"name": "Bill Sharman", "size": 6714},
{"name": "Jim Loscutoff", "size": 743},
{"name": "Tom Heinsohn", "size": 744}
]
},
{
"name": "1959",
"children": [
{"name": "Bill Russell", "size": 3938},
{"name": "Bob Cousy", "size": 3812},
{"name": "Bill Sharman", "size": 6714},
{"name": "Frank Ramsey", "size": 743},
{"name": "Tom Heinsohn", "size": 744}
]
},
{
"name": "1960",
"children": [
{"name": "Bill Russell", "size": 3938},
{"name": "Bob Cousy", "size": 3812},
{"name": "Bill Sharman", "size": 6714},
{"name": "Frank Ramsey", "size": 743},
{"name": "Tom Heinsohn", "size": 744}
]
},
{
"name": "1961",
"children": [
{"name": "Bill Russell", "size": 3938},
{"name": "Bob Cousy", "size": 3812},
{"name": "Sam Jones", "size": 6714},
{"name": "Frank Ramsey", "size": 743},
{"name": "Tom Heinsohn", "size": 744}
]
},
{
"name": "1962",
"children": [
{"name": "Bill Russell", "size": 3938},
{"name": "Bob Cousy", "size": 3812},
{"name": "Sam Jones", "size": 6714},
{"name": "Tom Sanders", "size": 743},
{"name": "Tom Heinsohn", "size": 744}
]
},
{
"name": "1963",
"children": [
{"name": "Bill Russell", "size": 3938},
{"name": "Bob Cousy", "size": 3812},
{"name": "Sam Jones", "size": 6714},
{"name": "Tom Sanders", "size": 743},
{"name": "John Havlicek", "size": 744}
]
},
{
"name": "1964",
"children": [
{"name": "Bill Russell", "size": 3938},
{"name": "John Havlicek", "size": 3812},
{"name": "Sam Jones", "size": 6714},
{"name": "K.C. Jones", "size": 743},
{"name": "Tom Sanders", "size": 744}
]
},
{
"name": "1965",
"children": [
{"name": "Bill Russell", "size": 3938},
{"name": "John Havlicek", "size": 3812},
{"name": "Sam Jones", "size": 6714},
{"name": "K.C. Jones", "size": 743},
{"name": "Tom Sanders", "size": 744}
]
},
{
"name": "1966",
"children": [
{"name": "Bill Russell", "size": 3938},
{"name": "John Havlicek", "size": 3812},
{"name": "Sam Jones", "size": 6714},
{"name": "K.C. Jones", "size": 743},
{"name": "Tom Sanders", "size": 744}
]
},
{
"name": "1968",
"children": [
{"name": "Bill Russell", "size": 3938},
{"name": "John Havlicek", "size": 3812},
{"name": "Sam Jones", "size": 6714},
{"name": "Bailey Howell", "size": 743},
{"name": "Tom Sanders", "size": 744}
]
},
{
"name": "1969",
"children": [
{"name": "Bill Russell", "size": 3938},
{"name": "John Havlicek", "size": 3812},
{"name": "Larry Siegfried", "size": 6714},
{"name": "Bailey Howell", "size": 743},
{"name": "Tom Sanders", "size": 744}
]
},
{
"name": "1974",
"children": [
{"name": "Dave Cowens", "size": 3938},
{"name": "John Havlicek", "size": 3812},
{"name": "Jo Jo White", "size": 6714},
{"name": "Paul Silas", "size": 743},
{"name": "Don Chaney", "size": 744}
]
},
{
"name": "1976",
"children": [
{"name": "Dave Cowens", "size": 3938},
{"name": "John Havlicek", "size": 3812},
{"name": "Jo Jo White", "size": 6714},
{"name": "Paul Silas", "size": 743},
{"name": "Charlie Scott", "size": 744}
]
},
{
"name": "1981",
"children": [
{"name": "Larry Bird", "size": 3938},
{"name": "Cedric Maxwell", "size": 3812},
{"name": "Robert Parish", "size": 6714},
{"name": "Chris Ford", "size": 743},
{"name": "Tiny Archibald", "size": 744}
]
},
{
"name": "1984",
"children": [
{"name": "Larry Bird", "size": 3938},
{"name": "Cedric Maxwell", "size": 3812},
{"name": "Robert Parish", "size": 6714},
{"name": "Dennis Johnson", "size": 743},
{"name": "Gerald Henderson", "size": 744}
]
},
{
"name": "1986",
"children": [
{"name": "Larry Bird", "size": 3938},
{"name": "Kevin McHale", "size": 3812},
{"name": "Robert Parish", "size": 6714},
{"name": "Dennis Johnson", "size": 743},
{"name": "Danny Ainge", "size": 744}
]
},
{
"name": "2008",
"children": [
{"name": "Paul Pierce", "size": 3938},
{"name": "Kevin Garnett", "size": 3812},
{"name": "Ray Allen", "size": 6714},
{"name": "Rajon Rondo", "size": 743},
{"name": "Kendrick Perkins", "size": 744}
]
}
]
},
{
"name": "Brooklyn Nets"
},
{
"name": "Charlotte Hornets"
},
{
"name": "Chicago Bulls",
"children": [
{
"name": "1991",
"children": [
{"name": "Michael Jordan", "size": 3938},
{"name": "Scottie Pippen", "size": 3812},
{"name": "Horace Grant", "size": 6714},
{"name": "Bill Cartwright", "size": 743},
{"name": "John Paxton", "size": 744}
]
},
{
"name": "1992",
"children": [
{"name": "Michael Jordan", "size": 3938},
{"name": "Scottie Pippen", "size": 3812},
{"name": "Horace Grant", "size": 6714},
{"name": "Bill Cartwright", "size": 743},
{"name": "John Paxton", "size": 744}
]
},
{
"name": "1993",
"children": [
{"name": "Michael Jordan", "size": 3938},
{"name": "Scottie Pippen", "size": 3812},
{"name": "Horace Grant", "size": 6714},
{"name": "Bill Cartwright", "size": 743},
{"name": "B.J. Armstrong", "size": 744}
]
},
{
"name": "1996",
"children": [
{"name": "Michael Jordan", "size": 3938},
{"name": "Scottie Pippen", "size": 3812},
{"name": "Ron Harper", "size": 6714},
{"name": "Luc Longley", "size": 743},
{"name": "Dennis Rodman", "size": 744}
]
},
{
"name": "1997",
"children": [
{"name": "Michael Jordan", "size": 3938},
{"name": "Scottie Pippen", "size": 3812},
{"name": "Ron Harper", "size": 6714},
{"name": "Luc Longley", "size": 743},
{"name": "Dennis Rodman", "size": 744}
]
},
{
"name": "1998",
"children": [
{"name": "Michael Jordan", "size": 3938},
{"name": "Scottie Pippen", "size": 3812},
{"name": "Ron Harper", "size": 6714},
{"name": "Luc Longley", "size": 743},
{"name": "Dennis Rodman", "size": 744}
]
}
]
},
{
"name": "Cleveland Cavaliers",
"children": [
{
"name": "2016",
"children": [
{"name": "LeBron James", "size": 3938},
{"name": "Kyrie Irving", "size": 3812},
{"name": "Kevin Love", "size": 6714},
{"name": "JR Smith", "size": 743},
{"name": "Timofey Mozgov", "size": 744}
]
}
]
},
{
"name": "Dallas Mavericks",
"children": [
{
"name": "2011",
"children": [
{"name": "Dirk Nowitzki", "size": 3938},
{"name": "Jason Kidd", "size": 3812},
{"name": "Tyson Chandler", "size": 6714},
{"name": "Jason Terry", "size": 743},
{"name": "Caron Butler", "size": 744}
]
}
]
},
{
"name": "Denver Nuggets"
},
{
"name": "Detroit Pistons",
"children": [
{
"name": "1989",
"children": [
{"name": "Isiah Thomas", "size": 3938},
{"name": "Joe Dumars", "size": 3812},
{"name": "Bill Laimbeer", "size": 6714},
{"name": "Rick Mahorn", "size": 743},
{"name": "Andrian Dantley", "size": 744}
]
},
{
"name": "1990",
"children": [
{"name": "Isiah Thomas", "size": 3938},
{"name": "Joe Dumars", "size": 3812},
{"name": "Bill Laimbeer", "size": 6714},
{"name": "James Edwards", "size": 743},
{"name": "Dennis Rodman", "size": 744}
]
},
{
"name": "2004",
"children": [
{"name": "Rip Hamilton", "size": 3938},
{"name": "Tayshaun Prince", "size": 3812},
{"name": "Chauncey Billups", "size": 6714},
{"name": "Ben Wallace", "size": 743},
{"name": "Mehmet Okur", "size": 744}
]
}
]
},
{
"name": "Golden State Warriors",
"children": [
{
"name": "1956",
"children": [
{"name": "Jack George", "size": 3938},
{"name": "Paul Arizin", "size": 3812},
{"name": "Neil Johnston", "size": 6714},
{"name": "Tom Gola", "size": 743},
{"name": "Joe Graboski", "size": 744}
]
},
{
"name": "1975",
"children": [
{"name": "Rick Barry", "size": 3938},
{"name": "Butch Beard", "size": 3812},
{"name": "Jamaal Wilkes", "size": 6714},
{"name": "Clifford Ray", "size": 743},
{"name": "Charles Johnson", "size": 744}
]
},
{
"name": "2015",
"children": [
{"name": "Stephen Curry", "size": 3938},
{"name": "Klay Thompson", "size": 3812},
{"name": "Draymond Green", "size": 6714},
{"name": "Harrison Barnes", "size": 743},
{"name": "Andrew Bogut", "size": 744}
]
}
]
},
{
"name": "Houston Rockets",
"children": [
{
"name": "1994",
"children": [
{"name": "Hakeem Olajuwon", "size": 3938},
{"name": "Robert Horry", "size": 3812},
{"name": "Kenny Smith", "size": 6714},
{"name": "Vernon Maxwell", "size": 743},
{"name": "Otis Thorpe", "size": 744}
]
},
{
"name": "1995",
"children": [
{"name": "Hakeem Olajuwon", "size": 3938},
{"name": "Robert Horry", "size": 3812},
{"name": "Kenny Smith", "size": 6714},
{"name": "Vernon Maxwell", "size": 743},
{"name": "Clyde Drexler", "size": 744}
]
}
]
},
{
"name": "Indiana Pacers"
},
{
"name": "LA Clippers"
},
{
"name": "Los Angeles Lakers",
"children": [
{
"name": "1949",
"children": [
{"name": "George Mikan", "size": 3938},
{"name": "Jim Pollard", "size": 3812},
{"name": "Herm Shaefer", "size": 6714},
{"name": "Don Carlson", "size": 743},
{"name": "Arnie Ferrin", "size": 744}
]
},
{
"name": "1950",
"children": [
{"name": "George Mikan", "size": 3938},
{"name": "Jim Pollard", "size": 3812},
{"name": "Vern Mikkelsen", "size": 6714},
{"name": "Arnie Ferrin", "size": 743},
{"name": "Herm Schaefer", "size": 744}
]
},
{
"name": "1952",
"children": [
{"name": "George Mikan", "size": 3938},
{"name": "Vern Mikkelsen", "size": 3812},
{"name": "Jim Pollard", "size": 6714},
{"name": "Slater Martin", "size": 743},
{"name": "Bob Harrison", "size": 744}
]
},
{
"name": "1953",
"children": [
{"name": "George Mikan", "size": 3938},
{"name": "Vern Mikkelsen", "size": 3812},
{"name": "Jim Pollard", "size": 6714},
{"name": "Slater Martin", "size": 743},
{"name": "Pep Saul", "size": 744}
]
},
{
"name": "1954",
"children": [
{"name": "George Mikan", "size": 3938},
{"name": "Jim Pollard", "size": 3812},
{"name": "Vern Mikkelsen", "size": 6714},
{"name": "Slater Martin", "size": 743},
{"name": "Clyde Lovellette", "size": 744}
]
},
{
"name": "1972",
"children": [
{"name": "Wilt Chamberlain", "size": 3938},
{"name": "Jerry West", "size": 3812},
{"name": "Jim McMilliam", "size": 6714},
{"name": "Gail Goodrich", "size": 743},
{"name": "Happy Hairston", "size": 744}
]
},
{
"name": "1980",
"children": [
{"name": "Norm Nixon", "size": 3938},
{"name": "Kareem Abdul-Jabbar", "size": 3812},
{"name": "Jamaal Wilkes", "size": 6714},
{"name": "Michael Cooper", "size": 743},
{"name": "Magic Johnson", "size": 744}
]
},
{
"name": "1982",
"children": [
{"name": "Norm Nixon", "size": 3938},
{"name": "Kareem Abdul-Jabbar", "size": 3812},
{"name": "Jamaal Wilkes", "size": 6714},
{"name": "Michael Cooper", "size": 743},
{"name": "Magic Johnson", "size": 744}
]
},
{
"name": "1985",
"children": [
{"name": "Magic Johnson", "size": 3938},
{"name": "James Worthy", "size": 3812},
{"name": "Kareem Abdul-Jabbar", "size": 6714},
{"name": "Bryon Scott", "size": 743},
{"name": "Michael Cooper", "size": 744}
]
},
{
"name": "1987",
"children": [
{"name": "Magic Johnson", "size": 3938},
{"name": "James Worthy", "size": 3812},
{"name": "Bryon Scott", "size": 6714},
{"name": "Kareem Abdul-Jabbar", "size": 743},
{"name": "A.C. Green", "size": 744}
]
},
{
"name": "1988",
"children": [
{"name": "Magic Johnson", "size": 3938},
{"name": "James Worthy", "size": 3812},
{"name": "Byron Scott", "size": 6714},
{"name": "Kareem Abdul-Jabbar", "size": 743},
{"name": "A.C. Green", "size": 744}
]
},
{
"name": "2000",
"children": [
{"name": "Kobe Bryant", "size": 3938},
{"name": "Shaquille O'Neal", "size": 3812},
{"name": "Ron Harper", "size": 6714},
{"name": "Glen Rice", "size": 743},
{"name": "A.C. Green", "size": 744}
]
},
{
"name": "2001",
"children": [
{"name": "Kobe Bryant", "size": 3938},
{"name": "Shaquille O'Neal", "size": 3812},
{"name": "Ron Harper", "size": 6714},
{"name": "Rick Fox", "size": 743},
{"name": "Horace Grant", "size": 744}
]
},
{
"name": "2002",
"children": [
{"name": "Kobe Bryant", "size": 3938},
{"name": "Shaquille O'Neal", "size": 3812},
{"name": "Rick Fox", "size": 6714},
{"name": "Samaki Walker", "size": 743},
{"name": "Derek Fisher", "size": 744}
]
},
{
"name": "2009",
"children": [
{"name": "Kobe Bryant", "size": 3938},
{"name": "Derek Fisher", "size": 3812},
{"name": "Pau Gasol", "size": 6714},
{"name": "Andrew Bynum", "size": 743},
{"name": "Lamar Odom", "size": 744}
]
},
{
"name": "2010",
"children": [
{"name": "Kobe Bryant", "size": 3938},
{"name": "Derek Fisher", "size": 3812},
{"name": "Pau Gasol", "size": 6714},
{"name": "Andrew Bynum", "size": 743},
{"name": "Metta World Peace", "size": 744}
]
}
]
},
{
"name": "Memphis Grizzlies"
},
{
"name": "Miami Heat",
"children": [
{
"name": "2006",
"children": [
{"name": "Dwyane Wade", "size": 3938},
{"name": "Shaquille O'Neal", "size": 3812},
{"name": "Udonis Haslem", "size": 6714},
{"name": "James Posey", "size": 743},
{"name": "Jason Williams", "size": 744}
]
},
{
"name": "2012",
"children": [
{"name": "Dwyane Wade", "size": 3938},
{"name": "LeBron James", "size": 3812},
{"name": "Chris Bosh", "size": 6714},
{"name": "Mario Chalmers", "size": 743},
{"name": "Joel Anthony", "size": 744}
]
},
{
"name": "2013",
"children": [
{"name": "Dwyane Wade", "size": 3938},
{"name": "LeBron James", "size": 3812},
{"name": "Chris Bosh", "size": 6714},
{"name": "Mario Chalmers", "size": 743},
{"name": "Udonis Haslem", "size": 744}
]
}
]
},
{
"name": "Milwaukee Bucks",
"children": [
{
"name": "1971",
"children": [
{"name": "Kareem Abdul-Jabbar", "size": 3938},
{"name": "Oscar Robertson", "size": 3812},
{"name": "Bob Dandridge", "size": 6714},
{"name": "Jon McGlocklin", "size": 743},
{"name": "Greg Smith", "size": 744}
]
}
]
},
{
"name": "Minnesota Timberwolves"
},
{
"name": "New Orleans Pelicans"
},
{
"name": "New York Knicks",
"children": [
{
"name": "1970",
"children": [
{"name": "Walt Frazier", "size": 3938},
{"name": "Willis Reed", "size": 3812},
{"name": "Dick Barnett", "size": 6714},
{"name": "Dave DeBusschere", "size": 743},
{"name": "Bill Bradley", "size": 744}
]
},
{
"name": "1973",
"children": [
{"name": "Walt Frazier", "size": 3938},
{"name": "Willis Reed", "size": 3812},
{"name": "Earl Monroe", "size": 6714},
{"name": "Dave DeBusschere", "size": 743},
{"name": "Bill Bradley", "size": 744}
]
}
]
},
{
"name": "OKC Thunder",
"children": [
{
"name": "1979 (Supersonics)",
"children": [
{"name": "Jack Sikma", "size": 3938},
{"name": "Dennis Johnson", "size": 3812},
{"name": "Gus Williams", "size": 6714},
{"name": "John Johnson", "size": 743},
{"name": "Lonnie Shelton", "size": 744}
]
}
]
},
{
"name": "Orlando Magic"
},
{
"name": "Philadelphia 76ers",
"children": [
{
"name": "1967",
"children": [
{"name": "Wilt Chamberlain", "size": 3938},
{"name": "Hal Greer", "size": 3812},
{"name": "Chet Walker", "size": 6714},
{"name": "Luke Jackson", "size": 743},
{"name": "Wali Jones", "size": 744}
]
},
{
"name": "1983",
"children": [
{"name": "Moses Malone", "size": 3938},
{"name": "Julius Erving", "size": 3812},
{"name": "Maurice Cheeks", "size": 6714},
{"name": "Andrew Toney", "size": 743},
{"name": "Marc Iavaroni", "size": 744}
]
}
]
},
{
"name": "Pheonix Suns"
},
{
"name": "Sacramento Kings",
"children": [
{
"name": "1951 (Royals)",
"children": [
{"name": "Arnie Risen", "size": 3938},
{"name": "Bob Davies", "size": 3812},
{"name": "Jack Coleman", "size": 6714},
{"name": "Bobby Wanzer", "size": 743},
{"name": "Arnie Johnson", "size": 744}
]
}
]
},
{
"name": "San Antonio Spurs",
"children": [
{
"name": "1999",
"children": [
{"name": "Tim Duncan", "size": 3938},
{"name": "David Robinson", "size": 3812},
{"name": "Avery Johnson", "size": 6714},
{"name": "Sean Elliot", "size": 743},
{"name": "Mario Elie", "size": 744}
]
},
{
"name": "2003",
"children": [
{"name": "Tim Duncan", "size": 3938},
{"name": "Tony Parker", "size": 3812},
{"name": "Bruce Bowan", "size": 6714},
{"name": "David Robinson", "size": 743},
{"name": "Stephen Jackson", "size": 744}
]
},
{
"name": "2005",
"children": [
{"name": "Tim Duncan", "size": 3938},
{"name": "Tony Parker", "size": 3812},
{"name": "Bruce Bowan", "size": 6714},
{"name": "Manu Ginobli", "size": 743},
{"name": "Rasho Nesterovic", "size": 744}
]
},
{
"name": "2007",
"children": [
{"name": "Tim Duncan", "size": 3938},
{"name": "Tony Parker", "size": 3812},
{"name": "Bruce Bowan", "size": 6714},
{"name": "Manu Ginobli", "size": 743},
{"name": "Brent Barry", "size": 744}
]
},
{
"name": "2014",
"children": [
{"name": "Tim Duncan", "size": 3938},
{"name": "Tony Parker", "size": 3812},
{"name": "Manu Ginobli", "size": 6714},
{"name": "Kawhi Leonard", "size": 743},
{"name": "Danny Green", "size": 744}
]
}
]
},
{
"name": "Toronoto Raptors"
},
{
"name": "Utah Jazz"
}
]
}
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.node {
cursor: pointer;
}
.node circle {
fill: #fff;
stroke: steelblue;
stroke-width: 1.5px;
}
.node text {
font: 14px sans-serif;
}
.link {
fill: none;
stroke: #ccc;
stroke-width: 1.5px;
}
</style>
<body>
<script src="//d3js.org/d3.v3.min.js"></script>
<script>
var margin = {top: 20, right: 120, bottom: 20, left: 120},
width = 960 - margin.right - margin.left,
height = 800 - margin.top - margin.bottom;
var i = 0,
duration = 750,
root;
var tree = d3.layout.tree()
.size([height, width]);
var diagonal = d3.svg.diagonal()
.projection(function(d) { return [d.y, d.x]; });
var svg = d3.select("body").append("svg")
.attr("width", width + margin.right + margin.left)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
d3.json("flare.json", function(error, flare) {
if (error) throw error;
root = flare;
root.x0 = height / 2;
root.y0 = 0;
function collapse(d) {
if (d.children) {
d._children = d.children;
d._children.forEach(collapse);
d.children = null;
}
}
root.children.forEach(collapse);
update(root);
});
d3.select(self.frameElement).style("height", "800px");
function update(source) {
// Compute the new tree layout.
var nodes = tree.nodes(root).reverse(),
links = tree.links(nodes);
// Normalize for fixed-depth.
nodes.forEach(function(d) { d.y = d.depth * 180; });
// Update the nodes…
var node = svg.selectAll("g.node")
.data(nodes, function(d) { return d.id || (d.id = ++i); });
// Enter any new nodes at the parent's previous position.
var nodeEnter = node.enter().append("g")
.attr("class", "node")
.attr("transform", function(d) { return "translate(" + source.y0 + "," + source.x0 + ")"; })
.on("click", click);
nodeEnter.append("circle")
.attr("r", 1e-6)
.style("fill", function(d) { return d._children ? "lightsteelblue" : "#fff"; });
nodeEnter.append("text")
.attr("x", function(d) { return d.children || d._children ? -10 : 10; })
.attr("dy", ".35em")
.attr("text-anchor", function(d) { return d.children || d._children ? "end" : "start"; })
.text(function(d) { return d.name; })
.style("fill-opacity", 1e-6);
// Transition nodes to their new position.
var nodeUpdate = node.transition()
.duration(duration)
.attr("transform", function(d) { return "translate(" + d.y + "," + d.x + ")"; });
nodeUpdate.select("circle")
.attr("r", 4.5)
.style("fill", function(d) { return d._children ? "lightsteelblue" : "#fff"; });
nodeUpdate.select("text")
.style("fill-opacity", 1);
// Transition exiting nodes to the parent's new position.
var nodeExit = node.exit().transition()
.duration(duration)
.attr("transform", function(d) { return "translate(" + source.y + "," + source.x + ")"; })
.remove();
nodeExit.select("circle")
.attr("r", 1e-6);
nodeExit.select("text")
.style("fill-opacity", 1e-6);
// Update the links…
var link = svg.selectAll("path.link")
.data(links, function(d) { return d.target.id; });
// Enter any new links at the parent's previous position.
link.enter().insert("path", "g")
.attr("class", "link")
.attr("d", function(d) {
var o = {x: source.x0, y: source.y0};
return diagonal({source: o, target: o});
});
// Transition links to their new position.
link.transition()
.duration(duration)
.attr("d", diagonal);
// Transition exiting nodes to the parent's new position.
link.exit().transition()
.duration(duration)
.attr("d", function(d) {
var o = {x: source.x, y: source.y};
return diagonal({source: o, target: o});
})
.remove();
// Stash the old positions for transition.
nodes.forEach(function(d) {
d.x0 = d.x;
d.y0 = d.y;
});
}
// Toggle children on click.
function click(d) {
if (d.children) {
d._children = d.children;
d.children = null;
} else {
d.children = d._children;
d._children = null;
}
update(d);
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment