diff options
Diffstat (limited to 'tranches_insight/static')
| -rw-r--r-- | tranches_insight/static/main.js | 41 |
1 files changed, 33 insertions, 8 deletions
diff --git a/tranches_insight/static/main.js b/tranches_insight/static/main.js index 74bc3cdd..b7b2a659 100644 --- a/tranches_insight/static/main.js +++ b/tranches_insight/static/main.js @@ -1,21 +1,46 @@ -g2 = new Dygraph(document.getElementById("graphdiv2"), +g1 = new Dygraph(document.getElementById("graph1"), [], // path to CSV file { labels: [], title: "Correlation numbers" } // options ); +g2 = new Dygraph(document.getElementById("graph2"), + [], // path to CSV file + { labels: [], + title: "Risk numbers" } // options + ); -document.getElementById('dropdown'). - addEventListener('change', function(e) { - var index = this.value.split("."); +function update_graph(g) { + return function(e) { + var payload = {i: document.getElementById('index').value, + s: document.getElementById('series').value, + t: document.getElementById('tenor').value, + g: document.getElementById('greek').value}; + console.log(g); + if( g.maindiv_.id == "graph1"){ + payload['g'] = "skew"; + } $.getJSON("_data", - {i: index[0], s: index[1], t: index[2]}, + payload, function(data){ var newdata = data["data"].map(function(e){ f = e.slice(1); f.unshift(new Date(e[0])); return f}); - g2.updateOptions({'file': newdata, 'labels': data['labels']}); + g.updateOptions({'file': newdata, 'labels': data['labels']}); }); - }); + } +}; + + +document.getElementById('index'). + addEventListener('change', update_graph(g1)); +document.getElementById('series'). + addEventListener('change', update_graph(g1)); +document.getElementById('tenor'). + addEventListener('change', update_graph(g1)); +document.getElementById('greek'). + addEventListener('change', update_graph(g2)); + var event = new Event('change'); -document.getElementById('dropdown').dispatchEvent(event); +document.getElementById('index').dispatchEvent(event); +document.getElementById('greek').dispatchEvent(event); |
