-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathapp.js
47 lines (35 loc) · 957 Bytes
/
app.js
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
$('form').on('submit', function(e){
e.preventDefault();
var d = {};
jQuery.map($('form').serializeArray(), function(n, i){
d[n['name']] = n['value'];
});
var data = calculate(d);
var graph = calculateGraphs(d);
var $o = $('#output').show();
_.forEach(data, function(v,k){
$o.find('[data-value=' + k + ']').text(v);
});
var gds = _.map(graph, function(v){
var vs = _.values(v.current)
var gd = {
current: {
key: vs[0],
value: vs[1]
}
};
gd.data = _.map(v.data, function(v){
var vs = _.values(v);
return {
key: vs[0],
value: vs[1]
}
});
return gd;
});
// $o.find('svg').remove();
// var f = $o.find('figure')
// drawGraph(gds[0], f[0]);
// drawGraph(gds[1], f[1]);
// drawGraph(gds[2], f[2]);
})