-
Notifications
You must be signed in to change notification settings - Fork 0
/
sla-maps.html
207 lines (164 loc) · 5.44 KB
/
sla-maps.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/2 999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Heathcare Facilities Cases</title>
</head>
<body>
<h2> Heathcare Facilities Cases </h2>
<style>
body {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size:12px;
}
svg {
font: 10px sans-serif;
}
svg { border:1px dotted #aaa;}
.chart {width:620px; margin-right:12px; margin-bottom:12px; border:1px dotted #eee; float:left}
.chart li { display:inline-block; width:180px;}
.box line,
.box rect,
.box circle {
fill: #fff;
stroke: #000;
stroke-width: 1.5px;
}
.box .center {
stroke-dasharray: 3,3;
}
.box .outlier {
fill: none;
stroke: #ccc;
}
</style>
<script src="d3.v3.min.js"></script>
<script >
function casesbystate(filename, div_id, color1, color2, color3) {
//Width and height
var w = 600;
var h = 400;
//Define map projection
var projection = d3.geo.albersUsa()
.translate([w/2, h/2])
.scale(w * 1.3);
//Define path generator
var path = d3.geo.path()
.projection(projection);
//Define number formatting
var formatAsThousands = d3.format(",1");
//Create SVG element
var svg = d3.select(div_id)
.append("svg")
.attr("width", w)
.attr("height", h);
//Load in GeoJSON data
d3.json("us-states.json", function(json) {
//Bind data and create one path per GeoJSON feature
svg.selectAll("path")
.data(json.features)
.enter()
.append("path")
.attr("d", path)
.style("fill", "#ccc")
.style("stroke", "#666");
//Load in cities data d3testdata
d3.csv(filename, function(data) {
console.log (data);
var groups = svg.selectAll("g")
.data(data)
.enter()
.append ("g")
.attr("transform", function(d) {
var x = projection([d.lon, d.lat])[0];
var y = projection([d.lon, d.lat])[1];
return "translate (" + x + "," + y + ")";
});
groups.append ("rect")
.attr("x", -6)
.attr("y", ( function (d) { return (d.ongoing/2 * (-30)); }))
.attr("width", 11)
.attr("height", ( function (d) { return (d.ongoing/2 * 30); }) )
.style("opacity", 0)
.style("fill", color1)
.style("margin-left", 1)
.attr("class", "ongoing")
// .on("click", function(d,i) {
// window.location ="/search-class-action-cases?title=&field_case_status_value=ONG&title_2=" + d.state;
// });
groups.append ("rect")
.attr("x", 6)
.attr("y", ( function (d) { return (d.settled/2 * (-30)); }))
.attr("width", 11)
.attr("height", ( function (d) { return (d.settled/2 * 30); }) )
.style("opacity", 0)
.style("fill", color2)
.style("margin-left", 1)
.attr("class", "settled")
// .on("click", function(d,i) {
// window.location ="/search-class-action-cases?title=&field_case_status_value=SET&title_2=" + d.state; });
groups.append ("rect")
.attr("x", 18)
.attr("y", ( function (d) { return (d.other/2 * (-30)); }))
.attr("width", 11)
.attr("height", ( function (d) { return (d.other/2 * 30); }) )
.style("opacity", 0)
.style("fill", color3)
.style("margin-left", 1)
.attr("class", "other") ;
var vertbars = d3.selectAll("rect");
vertbars.transition()
.delay(function(d, i) {
return i * 10;
})
.duration(1000)
// .style("fill", "steelblue")
.style("opacity", 0.9);
groups.on("mouseover", function() {
d3.select(this).select("circle")
.style("fill", "orange");
d3.select(this).selectAll("text")
.style("opacity", 1);
})
.on("mouseout", function() {
d3.select(this).select("circle")
.style("fill", "steelblue");
d3.select(this).selectAll("text")
.style("opacity", 0);
})
groups.append ("text")
.attr("x", 0)
.attr("y", 12)
.style ("opacity", 0)
.text ( function (d) { return (d.state ); })
groups.append ("text")
.attr("x", 0)
.attr("y", 22)
.style ("opacity", 0)
.text ( function (d) { return ("Total cases: " + d.allcases ); })
});
});
} // end function
// todo
// add scale/domain instead of resizing y
</script>
<div id="bystatebystatus" class="chart">
<h3> Number of cases by state by status </h3>
<ul>
<li> Ongoing 7 green</li>
<li> Settled 21 steelblue</li>
<li> Other 24 orange </li>
</ul>
<script type="text/javascript"> casesbystate("bystatebystatus-withgeo.csv", "#bystatebystatus", "green", "steelblue", "orange"); </script>
</div>
<div id="bystatebyallegation" class="chart">
<h3> Number of cases by state by Allegation </h3>
<ul>
<li> Non-Accounting 17 steelblue </li>
<li> Non-Restatement GAAP 23 blue</li>
<li> Restatement 13 orange</li>
</ul>
<script type="text/javascript"> casesbystate("bystatebyallegation-withgeo.csv", "#bystatebyallegation", "blue", "steelblue", "orange"); </script>
</div>
</body>
</html>