Skip to content

Commit

Permalink
Fixed #19078, proximate legend update fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
jszuminski committed Jun 14, 2023
1 parent e9ae7f5 commit 3d8459a
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions ts/Core/Legend/Legend.ts
Expand Up @@ -235,7 +235,6 @@ class Legend {
* Legend options.
*/
public init(chart: Chart, options: LegendOptions): void {

/**
* Chart of this legend.
*
Expand All @@ -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);
}

/**
Expand Down

0 comments on commit 3d8459a

Please sign in to comment.