From 640a77e8467311b5ffa89a644f0c465e4f8487ca Mon Sep 17 00:00:00 2001 From: TechMiX Date: Fri, 13 Nov 2020 01:23:19 +0100 Subject: [PATCH] fix legend bug on resize --- .../src/app/components/statistics/chartist.component.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/frontend/src/app/components/statistics/chartist.component.ts b/frontend/src/app/components/statistics/chartist.component.ts index a15c9cb9b..a1c68f1e0 100644 --- a/frontend/src/app/components/statistics/chartist.component.ts +++ b/frontend/src/app/components/statistics/chartist.component.ts @@ -319,7 +319,11 @@ Chartist.plugins.legend = function (options: any) { chart.on('created', function (data: any) { - if (isSelfUpdate) + const useLabels = chart instanceof Chartist.Pie && chart.data.labels && chart.data.labels.length; + const legendNames = getLegendNames(useLabels); + var dirtyChartData = (chart.data.series.length < legendNames.length); + + if (isSelfUpdate || dirtyChartData) return; function removeLegendElement() { @@ -476,8 +480,6 @@ Chartist.plugins.legend = function (options: any) { removeLegendElement(); const legendElement = createLegendElement(); - const useLabels = chart instanceof Chartist.Pie && chart.data.labels && chart.data.labels.length; - const legendNames = getLegendNames(useLabels); const seriesMetadata = initSeriesMetadata(useLabels); const legends: any = [];