aboutsummaryrefslogtreecommitdiffstats
path: root/python/risk_insight/static/indices.js
diff options
context:
space:
mode:
Diffstat (limited to 'python/risk_insight/static/indices.js')
-rw-r--r--python/risk_insight/static/indices.js49
1 files changed, 23 insertions, 26 deletions
diff --git a/python/risk_insight/static/indices.js b/python/risk_insight/static/indices.js
index d3cc002a..6ada9916 100644
--- a/python/risk_insight/static/indices.js
+++ b/python/risk_insight/static/indices.js
@@ -1,32 +1,29 @@
function update_graph(g) {
- return function(e) {
- var payload = {i: document.getElementById('index').value,
- s: document.getElementById('series').value,
- t: document.getElementById('tenor').value,
- w: document.getElementById('what').value};
- $.getJSON("_data_indices",
- payload,
- function(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']});
- });
- }
+ var payload = {i: $('index').value,
+ s: $('series').value,
+ t: $('tenor').value,
+ w: $('what').value};
+ query("_data_indices",
+ 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(event) {
- var g = new Dygraph(document.getElementById("graph"),
+document.addEventListener("DOMContentLoaded", function() {
+ var g = new Dygraph($("graph"),
[], // path to CSV file
- { labels: [],
- title: "Index quotes",
- showRoller: true,
- legend: "always"});
+ { labels: [],
+ title: "Index quotes",
+ showRoller: true,
+ legend: "always"});
["index", "series", "tenor", "what"].forEach(function(id) {
- document.getElementById(id).addEventListener('change',
- update_graph(g))});
- var event = new Event('change');
- document.getElementById('index').dispatchEvent(event);
-
+ $(id).addEventListener('change', function(){
+ update_graph(g)});
+ update_graph(g);
});