-
Notifications
You must be signed in to change notification settings - Fork 0
/
radar.html
160 lines (136 loc) · 5.09 KB
/
radar.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
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css">
<link rel="stylesheet" href="./external/css/radar.css">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js"></script>
<script type="text/javascript" src="./js/taln.widgets.chart.js"></script>
<script type="text/javascript" src="./external/js/radarChart.js"></script>
<title>UPF TENSOR components</title>
</head>
<body>
<div class="container-fluid">
<h1 align="center">TENSOR: UPF text analysis</h1>
</div>
<div class="container">
<div class="card">
<div class="card-header">Input text here:</div>
<div class="card-body">
<form id="inputForm">
<div class="form-group">
<!--label for="inputText">Input text here...</label -->
<textarea class="form-control" id="inputText" rows="7"></textarea>
</div>
<!--button type="submit" class="btn btn-success">Submit</button -->
<button type="submit" class="btn btn-primary btn-lg" id="btnLoad" data-loading-text="<i class='fa fa-spinner fa-spin '></i> Processing">Analyze</button>
</form>
</div>
</div>
</div>
<div id="result" class="container">
<div id="radar"></div>
</div>
<script type="text/javascript">
function spinButton() {
var button = $("#btnLoad");
button.data('original-text', button.html());
button.html(button.data('loading-text'));
setTimeout(function() {
button.html(button.data('original-text'));
}, 80000);
}
function unspinButton() {
var button = $("#btnLoad");
button.html(button.data('original-text'));
}
var margin = {top: 100, right: 100, bottom: 100, left: 100};
var color = d3.scale.ordinal()
.range(["#FF0000","#00FF00","#0000FF","#FFFF00","#00FFFF", "#FFFFFF"]);
var radarChartOptions = {
w: 500,
h: 500,
margin: margin,
maxValue: 0,
levels: 5,
roundStrokes: false,
roundGrid: false,
color: color,
opacityArea: 0.25
};
function receiveUrlResult(url, data, output) {
$.ajax({
type: "POST",
dataType: "json",
url: url
})
.done(function(result) {
var graphsData = profilinigToChart(result, data);
paintCharts(graphsData, output, radarChartOptions);
})
.fail(function(jqXHR, textStatus, errorThrown) {
var msg = '';
if (jqXHR.status === 0) {
msg = 'Not connect.\n Verify Network.';
} else if (jqXHR.status == 404) {
msg = 'Requested page not found. [404]';
} else if (jqXHR.status == 500) {
msg = 'Internal Server Error [500].';
} else if (textStatus === 'parsererror') {
msg = 'Requested JSON parse failed.';
} else if (textStatus === 'timeout') {
msg = 'Time out error.';
} else if (textStatus === 'abort') {
msg = 'Ajax request aborted.';
} else {
msg = 'Uncaught Error.\n' + jqXHR.responseText;
}
alert(msg);
})
.always(function(data) {});
};
function submitForm(type, url, loadingCallback, endLoadingCallback) {
typeof loadingCallback === 'function' && loadingCallback();
var jqxhr = $.ajax({
type: type,
dataType: "json",
url: url
})
.done(function(result) {
$("#radar").empty();
receiveUrlResult("./resources/baseRadar3.json", result["data"]["profiling"], "radar");
})
.fail(function(jqXHR, textStatus, errorThrown) {
var msg = '';
if (jqXHR.status === 0) {
msg = 'Not connect.\n Verify Network.';
} else if (jqXHR.status == 404) {
msg = 'Requested page not found. [404]';
} else if (jqXHR.status == 500) {
msg = 'Internal Server Error [500].';
} else if (textStatus === 'parsererror') {
msg = 'Requested JSON parse failed.';
} else if (textStatus === 'timeout') {
msg = 'Time out error.';
} else if (textStatus === 'abort') {
msg = 'Ajax request aborted.';
} else {
msg = 'Uncaught Error.\n' + jqXHR.responseText;
}
alert(msg);
})
.always(function(data) {
typeof endLoadingCallback === 'function' && endLoadingCallback();
});
}
$("#inputForm").submit(function(event) {
event.preventDefault();
var inputText = $("#inputText").val();
submitForm("POST", "./resources/resultChart.json", spinButton, unspinButton);
});
</script>