diff options
Diffstat (limited to 'risk_insight/risk_insight/static/indices.js')
| -rw-r--r-- | risk_insight/risk_insight/static/indices.js | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/risk_insight/risk_insight/static/indices.js b/risk_insight/risk_insight/static/indices.js index 4a019b18..d3cc002a 100644 --- a/risk_insight/risk_insight/static/indices.js +++ b/risk_insight/risk_insight/static/indices.js @@ -1,10 +1,3 @@ -g = new Dygraph(document.getElementById("graph"), - [], // path to CSV file - { labels: [], - title: "Index quotes", - showRoller: true, - legend: "always"}); - function update_graph(g) { return function(e) { var payload = {i: document.getElementById('index').value, @@ -23,14 +16,17 @@ function update_graph(g) { } }; +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); -document.getElementById('index'). - addEventListener('change', update_graph(g)); -document.getElementById('series'). - addEventListener('change', update_graph(g)); -document.getElementById('tenor'). - addEventListener('change', update_graph(g)); -document.getElementById('what'). - addEventListener('change', update_graph(g)); -var event = new Event('change'); -document.getElementById('index').dispatchEvent(event); +}); |
