From b87208a649496f61dad758c35457a68810351968 Mon Sep 17 00:00:00 2001 From: Risto Lahtela <24460436+AuroraLS3@users.noreply.github.com> Date: Fri, 23 Apr 2021 09:06:16 +0300 Subject: [PATCH] Clean-up updateGraphs function Affects: - #1861 --- .../main/resources/assets/plan/web/js/graphs.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Plan/common/src/main/resources/assets/plan/web/js/graphs.js b/Plan/common/src/main/resources/assets/plan/web/js/graphs.js index 7344dc9a2..43dd21199 100644 --- a/Plan/common/src/main/resources/assets/plan/web/js/graphs.js +++ b/Plan/common/src/main/resources/assets/plan/web/js/graphs.js @@ -711,13 +711,23 @@ function worldPie(id, worldSeries, gmSeries) { } function updateGraphs() { + // HighCharts nukes the scrollbar variable from the given parameter + // If the graph doesn't support srollbars (bar, pie and map charts for example) + // This workaround stores a copy of the scrollbar so that it can be set const scrollbar = {...Highcharts.theme.scrollbar}; - graphs.forEach((graph, index, array) => { + + function updateGraph(graph, index, array) { + // Empty objects can be left in the array if existing graph is re-rendered if (Object.keys(graph).length === 0) { array.splice(index, 1); return; } - Highcharts.theme["scrollbar"] = {...scrollbar}; + + // scrollbar workaround + if (!Highcharts.theme["scrollbar"]) Highcharts.theme["scrollbar"] = {...scrollbar}; + graph.update(Highcharts.theme); - }) + } + + graphs.forEach(updateGraph); }