From 3d8459aabb7b3b2572fff83f441999a2686de390 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Szumi=C5=84ski?= Date: Wed, 14 Jun 2023 12:09:09 +0200 Subject: [PATCH] Fixed #19078, proximate legend update fix. --- ts/Core/Legend/Legend.ts | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/ts/Core/Legend/Legend.ts b/ts/Core/Legend/Legend.ts index 020d6106eda..f64e1457e2c 100644 --- a/ts/Core/Legend/Legend.ts +++ b/ts/Core/Legend/Legend.ts @@ -235,7 +235,6 @@ class Legend { * Legend options. */ public init(chart: Chart, options: LegendOptions): void { - /** * Chart of this legend. * @@ -247,29 +246,29 @@ class Legend { this.setOptions(options); - if (options.enabled) { + const positionProximate = (): void => { + if (this.options.enabled && this.proximate) { + this.proximatePositions(); + this.positionItems(); + } + }; + if (options.enabled) { // Render it this.render(); - // move checkboxes + // Move checkboxes addEvent(this.chart, 'endResize', function (): void { this.legend.positionCheckboxes(); }); // On Legend.init and Legend.update, make sure that proximate layout // events are either added or removed (#18362). - addEvent( - this.chart, - 'render', - (): void => { - if (this.proximate) { - this.proximatePositions(); - this.positionItems(); - } - } - ); + addEvent(this.chart, 'render', positionProximate); } + + // Need to position the legend after update, #19078. + addEvent(this.chart, 'redraw', positionProximate); } /**