Clean-up updateGraphs function

Affects:
- #1861
This commit is contained in:
Risto Lahtela 2021-04-23 09:06:16 +03:00
parent 9ccbda0ebd
commit b87208a649

View File

@ -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);
}