index.html
5.12 KB
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
<html>
<head>
<script type="text/javascript" src="../bower_components/csvjson/csvjson.min.js"></script>
<script type="text/javascript" src="../src/ArrayUtils.js"></script>
<script type="text/javascript" src="../src/DataTypesUtils.js"></script>
<script type="text/javascript" src="../src/DataTypeConverter.js"></script>
<link rel="import" href="../bower_components/polymer/polymer.html">
<link rel="import" href="../bower_components/paper-progress/paper-progress.html">
<script type="text/javascript" src="../bower_components/webcomponentsjs/webcomponents-lite.min.js"></script>
<style is="custom-style">
paper-progress {
--paper-progress-active-color: #FFC107;
--paper-progress-container-color: white;
--paper-progress-height: 20px;
border: 1px solid black;
}
</style>
</head>
<body>
<h3>Dataset Visualizer</h3>
Dataset URL: <input id="txtDatasetUrl" type="text" style="width: 75%;"
value="http://ckan.routetopa.eu/dataset/fce7b89c-4c36-47c4-a486-7df5307a884e/resource/1b675fb7-8c9a-46d0-8f80-3e28afe4f4b5/download/litterwardennonulls.csv">
<input id="btnLoad" type="button" value="Load dataset" onclick="btnLoad_OnClick();">
<br/>
<table border="0">
<tr>
<td>Data homogeneity:</td>
<td><paper-progress id="barHomogeneity" value="0">sbiricuda</paper-progress></td>
<td id="barHomogeneityValue"></td>
</tr>
<!--<tr>
<td>Dataset Not Null Values:</td>
<td><paper-progress id="barNotNull" value="0">sbiricuda</paper-progress></td>
<td id="barNotNullValues"></td>
</tr>-->
<tr>
<td>Dataset Consistent Values:</td>
<td><paper-progress id="barErrors" value="0">sbiricuda</paper-progress></td>
<td id="barErrorsValues"></td>
</tr>
</table>
<br>
<table border=1>
<thead>
<tr id="trHeader">
</tr>
<tr id="trHeaderType">
</tr>
</thead>
<tbody id="tbody">
</tbody>
</table>
<script type="text/javascript">
window.onload = function() {
//var chartProcessor = new ChartProcessor();
//chartProcessor.inferDataTypes(urllnk);
}//EndFunction.
var httpGetAsync = function(theUrl, callback) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200)
callback(xhttp.responseText);
};
xhttp.open("GET", theUrl, true); // true for asynchronous
xhttp.send(null);
};//EndFunction.
function btnLoad_OnClick() {
//Take the url from the input text.
var valDatasetUrl = document.getElementById('txtDatasetUrl').value;
//Call Ajax to load the dataset content.
httpGetAsync(valDatasetUrl, update);
};//EndFunction.
function update(csvContent) {
console.log("update function.");
var _arrUtils = new ArrayUtils();
var reader = new csvjson();
var jsonDataset = reader.read(csvContent);
var _converter = new DataTypeConverter();
var path = [ "records", "*" ];
var processingResult = _converter.inferJsonDataType(jsonDataset, path);
var types = processingResult.types;
//Create the header table.
var trHeader = document.getElementById('trHeader');
ArrayUtils.IteratorOverKeys(types, function(field) {
var ntd = document.createElement("th");
ntd.innerHTML = field.name;
trHeader.appendChild(ntd);
});
debugger;
var trHeaderType = document.getElementById('trHeaderType');
ArrayUtils.IteratorOverKeys(types, function(field){
var ntd = document.createElement("th");
ntd.innerHTML = field.type + " (" + Math.round(field.typeConfidence * 100 * 100) / 100 + "%)";
trHeaderType.appendChild(ntd);
});
var processingResults = _converter.convert(processingResult);
var percentage = processingResult.qualityIndex.homogeneity*100;
var barHomogeneity = document.getElementById("barHomogeneity");
barHomogeneity.setAttribute("value", percentage);
document.getElementById("barHomogeneityValue").innerHTML = Math.round(percentage*100)/100 + "%";
/*var percentage = processingResult.qualityIndex.notNullValues*100;
var barConsistency = document.getElementById("barNotNull");
barConsistency.setAttribute("value", percentage);
document.getElementById("barNotNullValues").innerHTML = Math.round(percentage*100)/100 + "%";*/
var percentage = processingResult.qualityIndex.errors*100;
var barConsistency = document.getElementById("barErrors");
barConsistency.setAttribute("value", percentage);
document.getElementById("barErrorsValues").innerHTML = Math.round(percentage*100)/100 + "%";
}//EndFunction.
</script>
</body>
</html>