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
|
function update_graph(g) {
var payload = {i: $('index').value,
s: $('series').value,
t: $('tenor').value,
g: $('greek').value};
if( g.maindiv_.id == "graph1"){
payload['g'] = "corr_at_detach";
}
query("_data_tranches", payload,
function(data){
data = JSON.parse(data);
var newdata = data["data"].map(function(e){
f = e.slice(1);
f.unshift(new Date(e[0]));
return f});
g.updateOptions({'file': newdata, 'labels': data['labels']});
});
};
document.addEventListener("DOMContentLoaded", function() {
var g1 = new Dygraph($("graph1"), [], // path to CSV file
{ labels: [],
title: "Correlation numbers",
showRoller: true,
legend: "always"});
var g2 = new Dygraph($("graph2"), [], // path to CSV file
{ labels: [],
title: "Risk numbers",
showRoller: true,
legend: 'always'});
["index", "series", "tenor", "greek"].forEach(function(id) {
$(id).addEventListener('change', function(){
if(this.id != "greek"){
update_graph(g1);
}
update_graph(g2);
});
})
update_graph(g1);
update_graph(g2);
});
|