Skip to content

BubbleLegends hides when clicking the last legend, even if I prevent the event from happening #14080

Closed
@josejulio

Description

@josejulio

I prevent the event on legendItemClick from happening and I manage externally when to hide the legends.

Expected behaviour

When clicking on the last legend, the BubbleLegend remains showing because I'm controlling externally the legends show/hide.

Actual behaviour

When clicking on the last legend, the BubbleLegend hides

Live demo with steps to reproduce

https://jsfiddle.net/kzqhfa0r/6/
I'm preventing the Series 1 from being hidden

  1. Click on Series 2 to hide it.
  2. Click on Series 1 - It won't hide the Series, but the BubbleLegend will do

Product version

Reproduced using https://code.highcharts.com/highcharts-more.js

Affected browser(s)

At least Google Chrome Version 84.0.4147.105 (Official Build) (64-bit)

I suppose this happens because BubbleLegend is listening to legendItemClick, assuming the legend will toggle regardless.

addEvent(Series, 'legendItemClick', function (this: Highcharts.Series): void {

edit:

Actually the same happens with legend text is dimmed off(?), suppose is something similar.

I'm workarounding this issue by doing:

legendItemClick(e: any) {
    e.preventDefault();

    // Workaround to prevent the bubbleLegend from being hidden:
    this.chart.legend.update({ bubbleLegend: { enabled: true }});
    this.chart.legend.bubbleLegend.visible = true;
    // for the label, I'm doing something like this, but somewhere else
    if (this.visible) {
        this.show();
     }
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions