vendredi 16 avril 2021

Highcharts - Legends checkbox status not changing on

Can we show/hide all series except the last one only by clicking on the checkboxes and disable the legends label click?

Individual legend checkboxes should also work other than show/hide checkbox button.

When clicked on hide/show button last series should not be hidden, it should remain on the graph

https://jsfiddle.net/fx51vhs0/4/

$(function () {
  $('#container').highcharts({
    plotOptions: {
      series: {
        showCheckbox: true
      }
    },
    series: [{
      name: 's 1',
      data: [29.9, 71.5, 106.4]
    }, {
      name: 's 2',
      data: [19.9, 11.5, 26.4]
    }]
  }, function (chart) {
    Highcharts.each(chart.legend.allItems, function (p, i) {
      $(p.checkbox).change(
        function () {
          if (this.checked) {
            chart.legend.allItems[i].show();
          } else {
            chart.legend.allItems[i].hide();
          }
        });
    });

  });
});



Aucun commentaire:

Enregistrer un commentaire