Skip to content

Commit ce8a6eb

Browse files
author
vbpo
committed
beethoven json update
1 parent 8e69f66 commit ce8a6eb

File tree

3 files changed

+70
-85
lines changed

3 files changed

+70
-85
lines changed

beethovenTree.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"directed": true, "graph": {}, "nodes": [{"id": "spotify:artist:0CzNGQZX20KOuhdmmmwFkE"}, {"id": "spotify:artist:2SSWdLQmVLFOZ2tTm2PqHS"}, {"id": "spotify:artist:7xchFZamhl1sO3ySZ8Kws5"}, {"id": "spotify:artist:6q5JTAJA5oIGZk386ViRbL"}, {"id": "spotify:artist:2vIpN8nPvtMZUWyGicF2oj"}, {"id": "spotify:artist:6urvbTw4Mi2tGEEyBVXgMo"}, {"id": "spotify:artist:1DuaWBMPOTYKkyFZB9FcjF"}, {"id": "spotify:artist:32IBOb8yG3Yh9BuY8IMcqG"}, {"id": "spotify:artist:48Asba2lsKF1gSwQ0ed1j8"}, {"id": "spotify:artist:21h8E3aA7a9mjcUHbLpjxf"}, {"id": "spotify:artist:32i0ni9RO8Q7T7T7ZqkGU2"}, {"id": "spotify:artist:6aYN4hfugdwIgZlwag93do"}, {"id": "spotify:artist:1p4YAX8Nh6LiW3uPd49oAR"}, {"id": "spotify:artist:0s0wG03kPyu7MXERfcuxim"}, {"id": "spotify:artist:3cYlHOewTtDhkVIaEKZsOl"}, {"id": "spotify:artist:60adCptqwRkANTtVja0bvf"}, {"id": "spotify:artist:2GnOPGjzvccVNozglEdmFz"}, {"id": "spotify:artist:2rfkmr5WzRN9D9gAfb2ycd"}, {"id": "spotify:artist:60UJYXbYq8oGjl7FDqP0mW"}, {"id": "spotify:artist:3DoNXW0iKfMywQ1IiH3MC3"}, {"id": "spotify:artist:6pN2FraAoFMDQq2nPU4R3q"}, {"id": "spotify:artist:0sfHYTJehnSHxrVGCoDisL"}, {"id": "spotify:artist:0MvSBMGRQJY3mRwIbJsqF1"}, {"id": "spotify:artist:5Kb0Qf13EyYtVJvzCdI9M7"}, {"id": "spotify:artist:4GZbt7vP8w0VmWBL6J6Cy2"}, {"id": "spotify:artist:2eqNsX66FyKi3bnl1KSqZz"}, {"id": "spotify:artist:1uf45Fc4NypKo06YLc5J6q"}, {"id": "spotify:artist:5GTPSRMOmVVMX5eqYWaqqv"}, {"id": "spotify:artist:1ZGk0I7dP935efVVSs2Yjp"}, {"id": "spotify:artist:2mPWTnscb2ieCZdEHn3mbG"}, {"id": "spotify:artist:6XT1N2dSPU554mwwlDDUfG"}, {"id": "spotify:artist:0kdjTXFwhF9w9Cuscbgccu"}, {"id": "spotify:artist:5r6BbRI2QTDC9dv4rkSgCP"}, {"id": "spotify:artist:4AMvdGxJnXC0jxXPrZawRl"}, {"id": "spotify:artist:0YZRkFKKIsXZJXKOxEno0q"}, {"id": "spotify:artist:2aXPTgiEEifzSxFo2c8eUz"}, {"id": "spotify:artist:5CHXXNuReinAFGk3pjWgOH"}, {"id": "spotify:artist:7hrleJxjf4KJbeiQirb6BL"}, {"id": "spotify:artist:3WEe5Cpg29CUvsWWv4vRTT"}, {"id": "spotify:artist:3COykW4UPvB0DqwnzlnfWt"}, {"id": "spotify:artist:5hnUbiLAjGNZ9JsiWzOBRC"}, {"id": "spotify:artist:0vBafEFOLXtq5mZuhMgsyL"}, {"id": "spotify:artist:7vEPPI71V8dEHtEhPMAxWT"}, {"id": "spotify:artist:5UlxV9XPbZZX4d8HTdFO7P"}, {"id": "spotify:artist:1iyvtzGjtuQa1I5UGpzk6l"}, {"id": "spotify:artist:1iNPygduJOu0JnzasoDVLE"}, {"id": "spotify:artist:7ul6aaTwGaFWq0OZhxWrpd"}, {"id": "spotify:artist:0Do8lkxP8HHqyl7IgHjO45"}, {"id": "spotify:artist:20ZyXnHIi76iyl1O9PdDPQ"}, {"id": "spotify:artist:49TgMBH68KIFiOmLMoUOWY"}, {"id": "spotify:artist:694yYA2tOpl9qHCdzwkISn"}, {"id": "spotify:artist:0WbGXcZx7m4v2EJABJxfFg"}, {"id": "spotify:artist:0SPYS9NzfjFEplX7yD7PsK"}, {"id": "spotify:artist:42FGL88RlN0gKMgcI0kJiH"}, {"id": "spotify:artist:5b4EkkuooK98jClceGMe66"}, {"id": "spotify:artist:6tCHlxPHfuRpN3DRhpFfZR"}, {"id": "spotify:artist:1VBvt7cBPpnqowUS6QYsrQ"}, {"id": "spotify:artist:5sjJnaI3YhaO8KylpJk3gN"}, {"id": "spotify:artist:0LyfQWJT6nXafLPZqxe9Of"}, {"id": "spotify:artist:0sd6SprQ4G6y5wAaQVMRpB"}, {"id": "spotify:artist:2wOqMjp9TyABvtHdOSOTUS"}], "links": [{"source": 60, "target": 46}, {"source": 60, "target": 47}, {"source": 60, "target": 48}, {"source": 60, "target": 0}, {"source": 60, "target": 49}, {"source": 60, "target": 1}, {"source": 60, "target": 35}, {"source": 60, "target": 2}, {"source": 60, "target": 36}, {"source": 60, "target": 3}, {"source": 60, "target": 22}, {"source": 60, "target": 37}, {"source": 60, "target": 51}, {"source": 60, "target": 6}, {"source": 60, "target": 5}, {"source": 60, "target": 23}, {"source": 60, "target": 39}, {"source": 60, "target": 8}, {"source": 60, "target": 52}, {"source": 60, "target": 9}, {"source": 60, "target": 32}, {"source": 60, "target": 38}, {"source": 60, "target": 54}, {"source": 60, "target": 24}, {"source": 60, "target": 10}, {"source": 60, "target": 55}, {"source": 60, "target": 12}, {"source": 60, "target": 7}, {"source": 60, "target": 56}, {"source": 60, "target": 11}, {"source": 60, "target": 26}, {"source": 60, "target": 57}, {"source": 60, "target": 27}, {"source": 60, "target": 40}, {"source": 60, "target": 13}, {"source": 60, "target": 58}, {"source": 60, "target": 28}, {"source": 60, "target": 41}, {"source": 60, "target": 25}, {"source": 60, "target": 14}, {"source": 60, "target": 59}, {"source": 60, "target": 42}, {"source": 60, "target": 15}, {"source": 60, "target": 29}, {"source": 60, "target": 16}, {"source": 60, "target": 17}, {"source": 60, "target": 18}, {"source": 60, "target": 19}, {"source": 60, "target": 20}, {"source": 60, "target": 21}, {"source": 60, "target": 53}, {"source": 60, "target": 30}, {"source": 60, "target": 31}, {"source": 60, "target": 43}, {"source": 60, "target": 4}, {"source": 60, "target": 33}, {"source": 60, "target": 44}, {"source": 60, "target": 45}, {"source": 60, "target": 34}, {"source": 60, "target": 50}], "multigraph": false}
1+
{"id": "spotify:artist:2wOqMjp9TyABvtHdOSOTUS", "children": [{"id": "spotify:artist:7ul6aaTwGaFWq0OZhxWrpd"}, {"id": "spotify:artist:0Do8lkxP8HHqyl7IgHjO45"}, {"id": "spotify:artist:20ZyXnHIi76iyl1O9PdDPQ"}, {"id": "spotify:artist:0CzNGQZX20KOuhdmmmwFkE"}, {"id": "spotify:artist:49TgMBH68KIFiOmLMoUOWY"}, {"id": "spotify:artist:2SSWdLQmVLFOZ2tTm2PqHS"}, {"id": "spotify:artist:2aXPTgiEEifzSxFo2c8eUz"}, {"id": "spotify:artist:7xchFZamhl1sO3ySZ8Kws5"}, {"id": "spotify:artist:5CHXXNuReinAFGk3pjWgOH"}, {"id": "spotify:artist:6q5JTAJA5oIGZk386ViRbL"}, {"id": "spotify:artist:0MvSBMGRQJY3mRwIbJsqF1"}, {"id": "spotify:artist:7hrleJxjf4KJbeiQirb6BL"}, {"id": "spotify:artist:0WbGXcZx7m4v2EJABJxfFg"}, {"id": "spotify:artist:1DuaWBMPOTYKkyFZB9FcjF"}, {"id": "spotify:artist:6urvbTw4Mi2tGEEyBVXgMo"}, {"id": "spotify:artist:5Kb0Qf13EyYtVJvzCdI9M7"}, {"id": "spotify:artist:3COykW4UPvB0DqwnzlnfWt"}, {"id": "spotify:artist:48Asba2lsKF1gSwQ0ed1j8"}, {"id": "spotify:artist:0SPYS9NzfjFEplX7yD7PsK"}, {"id": "spotify:artist:21h8E3aA7a9mjcUHbLpjxf"}, {"id": "spotify:artist:5r6BbRI2QTDC9dv4rkSgCP"}, {"id": "spotify:artist:3WEe5Cpg29CUvsWWv4vRTT"}, {"id": "spotify:artist:5b4EkkuooK98jClceGMe66"}, {"id": "spotify:artist:4GZbt7vP8w0VmWBL6J6Cy2"}, {"id": "spotify:artist:32i0ni9RO8Q7T7T7ZqkGU2"}, {"id": "spotify:artist:6tCHlxPHfuRpN3DRhpFfZR"}, {"id": "spotify:artist:1p4YAX8Nh6LiW3uPd49oAR"}, {"id": "spotify:artist:32IBOb8yG3Yh9BuY8IMcqG"}, {"id": "spotify:artist:1VBvt7cBPpnqowUS6QYsrQ"}, {"id": "spotify:artist:6aYN4hfugdwIgZlwag93do"}, {"id": "spotify:artist:1uf45Fc4NypKo06YLc5J6q"}, {"id": "spotify:artist:5sjJnaI3YhaO8KylpJk3gN"}, {"id": "spotify:artist:5GTPSRMOmVVMX5eqYWaqqv"}, {"id": "spotify:artist:5hnUbiLAjGNZ9JsiWzOBRC"}, {"id": "spotify:artist:0s0wG03kPyu7MXERfcuxim"}, {"id": "spotify:artist:0LyfQWJT6nXafLPZqxe9Of"}, {"id": "spotify:artist:1ZGk0I7dP935efVVSs2Yjp"}, {"id": "spotify:artist:0vBafEFOLXtq5mZuhMgsyL"}, {"id": "spotify:artist:2eqNsX66FyKi3bnl1KSqZz"}, {"id": "spotify:artist:3cYlHOewTtDhkVIaEKZsOl"}, {"id": "spotify:artist:0sd6SprQ4G6y5wAaQVMRpB"}, {"id": "spotify:artist:7vEPPI71V8dEHtEhPMAxWT"}, {"id": "spotify:artist:60adCptqwRkANTtVja0bvf"}, {"id": "spotify:artist:2mPWTnscb2ieCZdEHn3mbG"}, {"id": "spotify:artist:2GnOPGjzvccVNozglEdmFz"}, {"id": "spotify:artist:2rfkmr5WzRN9D9gAfb2ycd"}, {"id": "spotify:artist:60UJYXbYq8oGjl7FDqP0mW"}, {"id": "spotify:artist:3DoNXW0iKfMywQ1IiH3MC3"}, {"id": "spotify:artist:6pN2FraAoFMDQq2nPU4R3q"}, {"id": "spotify:artist:0sfHYTJehnSHxrVGCoDisL"}, {"id": "spotify:artist:42FGL88RlN0gKMgcI0kJiH"}, {"id": "spotify:artist:6XT1N2dSPU554mwwlDDUfG"}, {"id": "spotify:artist:0kdjTXFwhF9w9Cuscbgccu"}, {"id": "spotify:artist:5UlxV9XPbZZX4d8HTdFO7P"}, {"id": "spotify:artist:2vIpN8nPvtMZUWyGicF2oj"}, {"id": "spotify:artist:4AMvdGxJnXC0jxXPrZawRl"}, {"id": "spotify:artist:1iyvtzGjtuQa1I5UGpzk6l"}, {"id": "spotify:artist:1iNPygduJOu0JnzasoDVLE"}, {"id": "spotify:artist:0YZRkFKKIsXZJXKOxEno0q"}, {"id": "spotify:artist:694yYA2tOpl9qHCdzwkISn"}]}

beethovenTreeVis.html

+68-83
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,69 @@
11
<!DOCTYPE html>
2-
<meta charset="utf-8">
3-
<!-- Taken from https://bl.ocks.org/mbostock/4063550 !-->
4-
<style>
5-
6-
.node circle {
7-
fill: #999;
8-
}
9-
10-
.node text {
11-
font: 10px sans-serif;
12-
}
13-
14-
.node--internal circle {
15-
fill: #555;
16-
}
17-
18-
.node--internal text {
19-
text-shadow: 0 1px 0 #fff, 0 -1px 0 #fff, 1px 0 0 #fff, -1px 0 0 #fff;
20-
}
21-
22-
.link {
23-
fill: none;
24-
stroke: #555;
25-
stroke-opacity: 0.4;
26-
stroke-width: 1.5px;
27-
}
28-
29-
</style>
30-
<svg width="960" height="1060"></svg>
31-
<script src="https://d3js.org/d3.v4.min.js"></script>
32-
<script>
33-
34-
var svg = d3.select("svg"),
35-
width = +svg.attr("width"),
36-
height = +svg.attr("height"),
37-
g = svg.append("g").attr("transform", "translate(" + (width / 2 + 40) + "," + (height / 2 + 90) + ")");
38-
39-
var stratify = d3.stratify()
40-
.parentId(function(d) { return d.id.substring(0, d.id.lastIndexOf(".")); });
41-
42-
var tree = d3.tree()
43-
.size([360, 500])
44-
.separation(function(a, b) { return (a.parent == b.parent ? 1 : 2) / a.depth; });
45-
46-
d3.json("https://raw.githubusercontent.com/akashlevy/Musical-Collab-Graph/master/beethovenTree.json?token=AKvcEejOtFA29OJx5KBAnHQTSHnghPC5ks5YgnoEwA%3D%3D", function(error, data) {
47-
if (error) throw error;
48-
49-
var root = tree(stratify(data));
50-
51-
var link = g.selectAll(".link")
52-
.data(root.descendants().slice(1))
53-
.enter().append("path")
54-
.attr("class", "link")
55-
.attr("d", function(d) {
56-
return "M" + project(d.x, d.y)
57-
+ "C" + project(d.x, (d.y + d.parent.y) / 2)
58-
+ " " + project(d.parent.x, (d.y + d.parent.y) / 2)
59-
+ " " + project(d.parent.x, d.parent.y);
60-
});
61-
62-
var node = g.selectAll(".node")
63-
.data(root.descendants())
64-
.enter().append("g")
65-
.attr("class", function(d) { return "node" + (d.children ? " node--internal" : " node--leaf"); })
66-
.attr("transform", function(d) { return "translate(" + project(d.x, d.y) + ")"; });
67-
68-
node.append("circle")
69-
.attr("r", 2.5);
70-
71-
node.append("text")
72-
.attr("dy", ".31em")
73-
.attr("x", function(d) { return d.x < 180 === !d.children ? 6 : -6; })
74-
.style("text-anchor", function(d) { return d.x < 180 === !d.children ? "start" : "end"; })
75-
.attr("transform", function(d) { return "rotate(" + (d.x < 180 ? d.x - 90 : d.x + 90) + ")"; })
76-
.text(function(d) { return d.id.substring(d.id.lastIndexOf(".") + 1); });
77-
});
78-
79-
function project(x, y) {
80-
var angle = (x - 90) / 180 * Math.PI, radius = y;
81-
return [radius * Math.cos(angle), radius * Math.sin(angle)];
82-
}
83-
84-
</script>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>d3.chart.layout.hierarchy.tree.radial</title>
6+
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
7+
<script src="https://rawgit.com/misoproject/d3.chart/master/d3.chart.min.js"></script>
8+
<script src="https://rawgit.com/bansaghi/d3.chart.layout.hierarchy/master/d3.chart.layout.hierarchy.js"></script>
9+
<style>
10+
html {
11+
display: table;
12+
margin: auto; }
13+
14+
#vis {
15+
width: 960px;
16+
height: 500px; }
17+
18+
.node {
19+
cursor: pointer; }
20+
21+
.node.leaf {
22+
cursor: default; }
23+
24+
.node circle {
25+
fill: lightsteelblue;
26+
stroke: steelblue;
27+
stroke-width: 1.5px; }
28+
29+
.node.leaf circle {
30+
fill: #fff; }
31+
32+
.node text {
33+
font-size: 11px; }
34+
35+
.link {
36+
fill: none;
37+
stroke: #ccc;
38+
stroke-width: 1.5px; }
39+
</style>
40+
</head>
41+
<body>
42+
43+
<div id="vis"></div>
44+
45+
<script>
46+
(function() {
47+
48+
d3.json("https://raw.githubusercontent.com/akashlevy/Musical-Collab-Graph/master/beethovenTree.json?token=AKvcEWs3BHMceIhxs0KRzrwr5xuvG9kpks5Ygny9wA%3D%3D", function(error, json) {
49+
50+
var tree = d3.select("#vis").append("svg")
51+
52+
.chart("tree.radial")
53+
54+
//.diameter(500)
55+
.radius(function(d) { if( d.size ) return Math.log(d.size); else return 3; })
56+
//.levelGap(200)
57+
.zoomable([0.1, 3])
58+
.collapsible(1)
59+
//.duration(200)
60+
//.sortable("_ASC_")
61+
;
62+
63+
tree.draw(json);
64+
65+
});
66+
}());
67+
</script>
68+
</body>
69+
</html>

pickle_to_json_no_img.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222

2323
# Convert to table
24-
data = json_graph.node_link_data(G, dict(id='id', source='source', target='target', key='key'));
24+
data = json_graph.tree_data(G, root = 'spotify:artist:2wOqMjp9TyABvtHdOSOTUS');
2525

2626
writefilename = sys.argv[2] if (len(sys.argv) > 2) else 'graph.json';
2727
f = open(writefilename, 'w');

0 commit comments

Comments
 (0)