score:1

Accepted answer

You can add some flag to avoid looping through the first chart.

  $.each(Highcharts.charts, function(i, chrt) {
    //
    // Flag to avoid looping through the first chart
    //
    if (i !== 0) {
      $.each(chrt.series, function(j, serie) {
        let tmp_key = serie.name.replace(/[\s,-]/g, '');
        if (!Object.keys(listed).includes(tmp_key)) {
          legend.append(
            '<div class="item ' + tmp_key + '"><div class="symbol" style="background-color:' +
            serie.color +
            '"></div><div class="serieName" id="">' +
            serie.name +
            '</div></div>'
          );
          listed[tmp_key] = [serie];
        } else {
          listed[tmp_key].push(serie);
        }
      });
    }
  });

Demo: https://jsfiddle.net/BlackLabel/yatz5m38/

score:0

A JSFiddle would be nice. Do notice though that

            if (serie.visible) serie.setVisible(false);
            else serie.setVisible(true);

can be simplified to serie.setVisible(!serie.visible)


Related Query

More Query from same tag