Skip to content

Commit 42522a1

Browse files
committed
Unfinished tree-map Concept style of govmap, v 0.1, using json, added .gitignore
1 parent a2b55d4 commit 42522a1

File tree

3 files changed

+180
-0
lines changed

3 files changed

+180
-0
lines changed

.gitignore

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# -----------------------------------------------------------------
2+
# .gitignore
3+
# Bare Minimum Git
4+
# http://ironco.de/bare-minimum-git/
5+
# ver 20170502
6+
#
7+
# From the root of your project run
8+
# curl -O https://gist.githubusercontent.com/salcode/10017553/raw/.gitignore
9+
# to download this file
10+
#
11+
# This file is tailored for a general web project, it
12+
# is NOT optimized for a WordPress project. See
13+
# https://gist.github.com/salcode/b515f520d3f8207ecd04
14+
# for a WordPress specific .gitignore
15+
#
16+
# This file specifies intentionally untracked files to ignore
17+
# http://git-scm.com/docs/gitignore
18+
#
19+
# NOTES:
20+
# The purpose of gitignore files is to ensure that certain files not
21+
# tracked by Git remain untracked.
22+
#
23+
# To ignore uncommitted changes in a file that is already tracked,
24+
# use `git update-index --assume-unchanged`.
25+
#
26+
# To stop tracking a file that is currently tracked,
27+
# use `git rm --cached`
28+
#
29+
# Change Log:
30+
# 20170502 unignore composer.lock
31+
# 20170502 ignore components loaded via Bower
32+
# 20150326 ignore jekyll build directory `/_site`
33+
# 20150324 Reorganized file to list ignores first and whitelisted last,
34+
# change WordPress .gitignore link to preferred gist,
35+
# add curl line for quick installation
36+
# ignore composer files (vendor directory and lock file)
37+
# 20140606 Add .editorconfig as a tracked file
38+
# 20140418 remove explicit inclusion
39+
# of readme.md (this is not an ignored file by default)
40+
# 20140407 Initially Published
41+
#
42+
# -----------------------------------------------------------------
43+
44+
# ignore all files starting with . or ~
45+
.*
46+
~*
47+
48+
# ignore node/grunt dependency directories
49+
node_modules/
50+
51+
# ignore composer vendor directory
52+
/vendor
53+
54+
# ignore components loaded via Bower
55+
/bower_components
56+
57+
# ignore jekyll build directory
58+
/_site
59+
60+
# ignore OS generated files
61+
ehthumbs.db
62+
Thumbs.db
63+
64+
# ignore Editor files
65+
*.sublime-project
66+
*.sublime-workspace
67+
*.komodoproject
68+
69+
# ignore log files and databases
70+
*.log
71+
*.sql
72+
*.sqlite
73+
74+
# ignore compiled files
75+
*.com
76+
*.class
77+
*.dll
78+
*.exe
79+
*.o
80+
*.so
81+
82+
# ignore packaged files
83+
*.7z
84+
*.dmg
85+
*.gz
86+
*.iso
87+
*.jar
88+
*.rar
89+
*.tar
90+
*.zip
91+
92+
# -------------------------
93+
# BEGIN Whitelisted Files
94+
# -------------------------
95+
96+
# track these files, if they exist
97+
!.gitignore
98+
!.editorconfig

GovMap.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "US GOVERNMENT",
3+
"value": 100,
4+
"children": [
5+
{
6+
"name": "Legislative",
7+
"value": 75,
8+
"children":[
9+
{"name": "Senate", "value": 25},
10+
{"name": "House of Representatives ", "value": 25}
11+
]
12+
},
13+
{
14+
"name": "Executive",
15+
"value": 75,
16+
"children":[
17+
{"name": "President", "value": 25}
18+
]
19+
},
20+
{
21+
"name": "Judicial",
22+
"value": 75,
23+
"children":[
24+
{"name": "Supreme Court", "value": 25}
25+
]
26+
}
27+
28+
]
29+
}

Govmap.html

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<!doctype html>
2+
<html>
3+
4+
<head>
5+
<title>Project Civics GovMap</title>
6+
<script src="http://d3js.org/d3.v4.min.js"></script>
7+
</head>
8+
9+
<body>
10+
11+
<script>
12+
13+
var color = d3.scale.category10();
14+
15+
var canvas = d3.select("body")
16+
.append("svg")
17+
.attr("width", 500)
18+
.attr("height", 500);
19+
20+
d3.json("GovMap.json", function (data) {
21+
22+
var treemap = d3.layout.treemap()
23+
.size([500,500])
24+
.nodes(data)
25+
var cells = canvas.selectAll(".cell")
26+
.data(treemap)
27+
.enter()
28+
.append("g")
29+
.attr("class", "cell")
30+
31+
cells.append("rect")
32+
.attr("x", function (d) { return d.x; })
33+
.attr("y", function (d) { return d.y; })
34+
.attr("width", function (d) { return d.dx; })
35+
.attr("height", function (d) { return d.dy; })
36+
.attr("fill", function (d) { return d.children ? null : color(d.parent.name); })
37+
.attr("stroke", "#fff")
38+
39+
cells.append("text")
40+
.attr("x", function(d) { return d.x + d.dx / 2})
41+
.attr("y", function(d) { return d.y +d.dy / 2 })
42+
.attr("text-anchor","middle")
43+
.text(function (d) { return d.name; })
44+
45+
console.log(treemap);
46+
47+
})
48+
49+
</script>
50+
51+
</body>
52+
53+
</html>

0 commit comments

Comments
 (0)