-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
189 lines (179 loc) · 4.45 KB
/
index.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
<!DOCTYPE html>
<meta charset="utf-8" />
<!-- Load d3.js -->
<script src="https://d3js.org/d3.v4.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<!-- Create a div where the graph will take place -->
<div id="my_dataviz"></div>
<div>
<span class="box">
<form action="#" method="post" class="demoForm" id="demoForm">
<fieldset>
<legend>Choose Disease(s) to enlighten</legend>
<p>
<label
><input
type="checkbox"
name="disease[]"
value="amr"
onclick="toggle(1);"
checked
/>
AMR</label
>
<label
><input
type="checkbox"
name="disease[]"
value="cancer"
onclick="toggle(2);"
checked
/>
Cancer</label
>
<label
><input
type="checkbox"
name="disease[]"
value="cholera"
onclick="toggle(3);"
checked
/>
Cholera</label
>
<label
><input
type="checkbox"
name="disease[]"
value="diabetes"
onclick="toggle(4);"
checked
/>
Diabetes</label
>
<label
><input
type="checkbox"
name="disease[]"
value="Diahhorea"
onclick="toggle(5);"
checked
/>
Diahhorea</label
>
<label
><input
type="checkbox"
name="disease[]"
value="Measles"
onclick="toggle(6);"
checked
/>
Measles</label
>
<label
><input
type="checkbox"
name="disease[]"
value="Accidents"
onclick="toggle(7);"
checked
/>
Road Traffic Accidents</label
>
</p>
</fieldset>
</form>
</span>
</div>
<style>
<style>
.tooltip {
position: relative;
display: inline-block;
border-bottom: 1px dotted black;
}
.tooltip .tooltiptext {
visibility: hidden;
width: 120px;
background-color: black;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px 0;
/* Position the tooltip */
position: absolute;
z-index: 1;
}
.tooltip:hover .tooltiptext {
visibility: visible;
}
</style>
</style>
<script>
function toggle(id) {
if ($("#" + id).is(":visible")) {
$("#" + id).hide(1000);
} else {
$("#" + id).show(1000);
}
}
// set the dimensions and margins of the graph
var margin = { top: 30, right: 30, bottom: 70, left: 60 },
width = 460 - margin.left - margin.right,
height = 400 - margin.top - margin.bottom;
// append the svg object to the body of the page
var svg = d3
.select("#my_dataviz")
.append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
// Parse the Data
d3.csv(
"https://raw.githubusercontent.com/iGEM-IISER-Tirupati/2020-Editable/master/AMR-graph.csv",
function (data) {
// X axis
var x = d3
.scaleBand()
.range([0, width])
.domain(
data.map(function (d) {
return d.Country;
})
)
.padding(0.2);
svg
.append("g")
.attr("transform", "translate(0," + height + ")")
.call(d3.axisBottom(x))
.selectAll("text")
.attr("transform", "translate(-10,0)rotate(-45)")
.style("text-anchor", "end");
// Add Y axis
var y = d3.scaleLinear().domain([0, 30000]).range([height, 0]);
svg.append("g").call(d3.axisLeft(y));
// Bars
svg
.selectAll("mybar")
.data(data)
.enter()
.append("rect")
.attr("id", function (d) {
return d.id;
})
.attr("x", function (d) {
return x(d.Country);
})
.attr("y", function (d) {
return y(d.Value);
})
.attr("width", x.bandwidth())
.attr("height", function (d) {
return height - y(d.Value);
})
.attr("fill", "#69b3a2");
}
);
</script>