-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathalgae.html
153 lines (127 loc) · 4.89 KB
/
algae.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
<!DOCTYPE html>
<html lang="en">
<title>Potholes Filled</title>
<head>
<link rel="stylesheet" href="https://cdn.rawgit.com/twbs/bootstrap/v4-dev/dist/css/bootstrap.css">
<script src="https://cdn.rawgit.com/twbs/bootstrap/v4-dev/dist/js/bootstrap.js"></script>
<meta charset="utf-8">
<style>
h1 {
font: 18px sans-serif;
}
p {
font: 15px sans-serif;
}
table {
border-collapse: collapse;
border: 2px black solid;
font: 12px sans-serif;
}
th {
border: 1px black solid;
padding: 5px;
background-color: #F28B27;
color: white;
}
td {
border: 1px black solid;
padding: 5px;
}
tr:nth-child(even) {background-color: #CACACA}
tr:hover {background-color: #F28B27;
color: black;
}
#potholeCount{
font-size: 20px;
font-weight: bold;
color: green;
}
</style>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/alasql//0.3/alasql.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx.core.min.js"></script>
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
<script type='text/javascript'>//<![CDATA[
window.onload=function(){
window.downloadCSV = function downloadCSV() {
alasql('SELECT * INTO CSV("https://opendata.arcgis.com/datasets/d4e8aa90043a4201b1d83e059558bef2_0.csv",{headers:true}) \
FROM HTML("#algaetable",{headers:true})');
}
}//]]>
</script>
</head>
<body>
<div id="container">
<script src="http://d3js.org/d3.v3.min.js"></script>
<script type="text/javascript"charset="utf-8">
var columns = ["DATE", "SAMPLE LOCATION", "Test Type", "Detection Result"];
d3.csv("https://opendata.arcgis.com/datasets/d4e8aa90043a4201b1d83e059558bef2_0.csv", function(error, data) {
// Print the table by placing a `div` with `id` of `container`
// below, e.g. <div id="container"></div>
var table = d3.select("#container").append("table").attr("class", "order-table table").attr("id", "algaetable"),
thead = table.append("thead"),
tbody = table.append("tbody");
thead.append("tr")
.selectAll("th")
.data(columns)
.enter()
.append("th")
.text(function(column) { return column; });
var rows = tbody.selectAll("tr")
.data(data)
.enter()
.append("tr");
var cells = rows.selectAll("td")
.data(function(row) {
return columns.map(function(column) {
return {column: column, value: row[column]};
});
})
.enter()
.append("td")
.text(function(d) { return d.value; });
document.getElementById("potholeCount").innerHTML = data.length;
});
(function(document) {
'use strict';
var LightTableFilter = (function(Arr) {
var _input;
function _onInputEvent(e) {
_input = e.target;
var tables = document.getElementsByClassName(_input.getAttribute('data-table'));
Arr.forEach.call(tables, function(table) {
Arr.forEach.call(table.tBodies, function(tbody) {
Arr.forEach.call(tbody.rows, _filter);
});
});
}
function _filter(row) {
var text = row.textContent.toLowerCase(), val = _input.value.toLowerCase();
row.style.display = text.indexOf(val) === -1 ? 'none' : 'table-row';
}
return {
init: function() {
var inputs = document.getElementsByClassName('light-table-filter');
Arr.forEach.call(inputs, function(input) {
input.oninput = _onInputEvent;
});
}
};
})(Array.prototype);
document.addEventListener('readystatechange', function() {
if (document.readyState === 'complete') {
LightTableFilter.init();
}
});
})(document);
document.querySelector("button").addEventListener("click", function () {
var html = document.querySelector("table").outerHTML;
export_table_to_csv(html, "table.csv");
});
</script>
</div>
</body>
</html>