Skip to content

Commit 69cc33e

Browse files
committed
first commit
0 parents  commit 69cc33e

25 files changed

+5374
-0
lines changed

.gitignore

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Xcode
2+
#
3+
build/
4+
*.pbxuser
5+
!default.pbxuser
6+
*.mode1v3
7+
!default.mode1v3
8+
*.mode2v3
9+
!default.mode2v3
10+
*.perspectivev3
11+
!default.perspectivev3
12+
xcuserdata
13+
*.xccheckout
14+
*.moved-aside
15+
DerivedData
16+
*.hmap
17+
*.ipa
18+
*.xcuserstate
19+
20+
# CocoaPods
21+
#
22+
# We recommend against adding the Pods directory to your .gitignore. However
23+
# you should judge for yourself, the pros and cons are mentioned at:
24+
# http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
25+
#
26+
Pods/
27+
28+
#temp
29+
*.swp
30+
*.swo
31+
.DS_Store
32+
Thumbs.db
33+
node_modules/

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Nsobject inheritance topology

assets/base.css

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
html, body {
2+
margin: 0;
3+
padding: 0;
4+
}
5+
.node {
6+
font: 10px sans-serif;
7+
}
8+
.node text {
9+
cursor: zoom-in;
10+
}
11+
.zoomIn {
12+
cursor: zoom-out;
13+
}
14+
.zoomIn text {
15+
cursor: pointer;
16+
}
17+
.node circle {
18+
fill: #fff;
19+
stroke: steelblue;
20+
stroke-width: .5px;
21+
}
22+
.link {
23+
fill: none;
24+
stroke: #aaa;
25+
stroke-width: .5px;
26+
}

assets/d3.v3.min.js

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/init.js

+112
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
'use strict';
2+
3+
var radius = 50;
4+
var diameter = 960 * radius;
5+
6+
var tree = d3
7+
.layout
8+
.tree()
9+
.size([360, diameter / 2 - 120])
10+
.separation(function(a, b) {
11+
return (a.parent == b.parent ? 1 : 2) / a.depth;
12+
});
13+
14+
var diagonal = d3
15+
.svg
16+
.diagonal
17+
.radial()
18+
.projection(function(d) {
19+
return [d.y, d.x / 180 * Math.PI];
20+
});
21+
22+
var svg = d3
23+
.select('body')
24+
.append('svg')
25+
.attr('width', diameter)
26+
.attr('height', diameter)
27+
.append('g')
28+
.attr('transform', 'translate(' + diameter / 2 + ',' + diameter / 2 + ')');
29+
30+
d3.json('data/inheritance.json', function(error, root) {
31+
32+
if (error) {
33+
throw error;
34+
}
35+
36+
var nodes = tree.nodes(root);
37+
var links = tree.links(nodes);
38+
39+
var link = svg
40+
.selectAll('.link')
41+
.data(links)
42+
.enter()
43+
.append('path')
44+
.attr('class', 'link')
45+
.attr('d', diagonal);
46+
47+
var node = svg
48+
.selectAll('.node')
49+
.data(nodes)
50+
.enter().append('g')
51+
.attr('class', 'node')
52+
.attr('transform', function(d) {
53+
return 'rotate(' + (d.x - 90) + ')translate(' + d.y + ')';
54+
});
55+
56+
node
57+
.append('circle')
58+
.attr('r', 4.5);
59+
60+
node
61+
.append('text')
62+
.attr('id', function(d) {
63+
return d.name;
64+
})
65+
.attr('dy', '.31em')
66+
.attr('text-anchor', function(d) {
67+
return d.x < 180 ? 'start' : 'end';
68+
})
69+
.attr('transform', function(d) {
70+
return d.x < 180 ? 'translate(8)' : 'rotate(180)translate(-8)';
71+
})
72+
.text(function(d) {
73+
return d.name;
74+
});
75+
76+
d3
77+
.select('body')
78+
.style('zoom', 2 / radius);
79+
80+
document.addEventListener('click', function(e) {
81+
var target = e.target;
82+
83+
if (target.nodeName.toUpperCase() === 'TEXT') {
84+
var toggle = document.body.className === 'zoomIn';
85+
var text = target.innerHTML.trim();
86+
87+
if (toggle) {
88+
window.open('https://developer.apple.com/search/?q=' + text + '&platform=iOS');
89+
return;
90+
}
91+
92+
document.body.className = 'zoomIn';
93+
94+
d3
95+
.select('body')
96+
.style('zoom', 1);
97+
zoom.to({
98+
element: document.querySelector('#' + text),
99+
callback: function() {
100+
},
101+
padding: 200
102+
});
103+
} else {
104+
d3
105+
.select('body')
106+
.style('zoom', 2 / radius);
107+
108+
zoom.out();
109+
document.body.className = '';
110+
}
111+
});
112+
});

assets/tree.css

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
body {
2+
background-color: #fafafa;
3+
margin: 0;
4+
}
5+
6+
#header, #footer {
7+
z-index: 1;
8+
display: block;
9+
font-size: 30px;
10+
font-weight: 300;
11+
text-shadow: 0 1px 0 #fff;
12+
}
13+
14+
#header.inverted, #footer.inverted {
15+
color: #fff;
16+
text-shadow: 0 1px 4px #000;
17+
}
18+
19+
#header {
20+
top: 20px;
21+
right: 10px;
22+
width: 300px;
23+
text-align: right;
24+
}
25+
26+
#footer {
27+
top: 520px;
28+
right: 10px;
29+
width: 300px;
30+
text-align: right;
31+
}
32+
33+
rect {
34+
fill: none;
35+
pointer-events: all;
36+
}
37+
38+
pre {
39+
font-size: 18px;
40+
}
41+
42+
line {
43+
stroke: #000;
44+
stroke-width: 1px;
45+
}
46+
.comment {
47+
color: #777;
48+
font-style: oblique;
49+
}
50+
51+
.number {
52+
color: #369;
53+
}
54+
55+
.class, .special {
56+
color: #1181B8;
57+
}
58+
59+
a:link, a:visited {
60+
color: steelblue;
61+
text-decoration: none;
62+
}
63+
64+
a:hover {
65+
color: #666;
66+
}
67+
68+
.node circle {
69+
cursor: pointer;
70+
fill: #fff;
71+
stroke: steelblue;
72+
stroke-width: .8px;
73+
}
74+
75+
.node text {
76+
font-size: 10px;
77+
cursor: pointer;
78+
}
79+
80+
path.link {
81+
fill: none;
82+
stroke: #ccc;
83+
stroke-width: 1px;
84+
}

0 commit comments

Comments
 (0)