diff --git a/web/static/chart_functions.js b/web/static/chart_functions.js index bf81e5d..43cf2fa 100644 --- a/web/static/chart_functions.js +++ b/web/static/chart_functions.js @@ -144,27 +144,30 @@ function sparkline_summary_chart(jsonData, element) { function fill_charts() { document.querySelectorAll(".chartjs-chart").forEach(function (el) { - var url = el.dataset.chartEndpoint; - var type = el.dataset.chartType; - - fetch(url) - .then(response => { - if (!response.ok) { - console.log(response); - throw new Error("Fetch response was not ok!") - } - return response.json(); - }).then(jsonData => { - if (type == "historical_vs_current") { - historical_vs_current_chart(jsonData, el); - } else if (type == "sparkline_summary") { - sparkline_summary_chart(jsonData, el); - } - }).catch(error => { - console.error("Unable to set up chart: ", error) - }); - + fill_chart(el); }); } -export {fill_charts} +function fill_chart(el) { + var url = el.dataset.chartEndpoint; + var type = el.dataset.chartType; + + fetch(url) + .then(response => { + if (!response.ok) { + console.log(response); + throw new Error("Fetch response was not ok!") + } + return response.json(); + }).then(jsonData => { + if (type == "historical_vs_current") { + historical_vs_current_chart(jsonData, el); + } else if (type == "sparkline_summary") { + sparkline_summary_chart(jsonData, el); + } + }).catch(error => { + console.error("Unable to set up chart: ", error) + }); +} + +export {fill_charts, fill_chart} diff --git a/web/static/index.js b/web/static/index.js index b9bfed8..23bfc11 100644 --- a/web/static/index.js +++ b/web/static/index.js @@ -1,4 +1,4 @@ -import {fill_charts} from "./chart_functions.js"; +import {fill_charts, fill_chart} from "./chart_functions.js"; import {register_dropdowns} from "./dropdowns.js"; @@ -33,7 +33,7 @@ function register_nav_links() { function register_handlers() { register_nav_links(); - fill_charts(); + //fill_charts(); register_dropdowns(); } @@ -57,4 +57,4 @@ const trigger_table_animation = debounce(load_in_table, 100); const trigger_reset_handlers = debounce(register_handlers, 200); -export {trigger_reset_handlers, trigger_table_animation}; +export {trigger_reset_handlers, trigger_table_animation, fill_chart}; diff --git a/web/templates/index.html b/web/templates/index.html index 1965230..2e0d444 100644 --- a/web/templates/index.html +++ b/web/templates/index.html @@ -61,15 +61,34 @@