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.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/python/risk_insight/static/indices.js b/python/risk_insight/static/indices.js
new file mode 100644
index 00000000..d3cc002a
--- /dev/null
+++ b/python/risk_insight/static/indices.js
@@ -0,0 +1,32 @@
+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']});
+ });
+ }
+};
+
+document.addEventListener("DOMContentLoaded", function(event) {
+ var g = new Dygraph(document.getElementById("graph"),
+ [], // path to CSV file
+ { 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);
+
+});