Toggling series on and off via chart API

This demo shows how we can toggle a series off and on using its hide() and show() methods.

Relevant code:

function toggle(index) {
  let series = chart.series.getIndex(index);
  toggleSeries(series);
}

function toggleSeries(series) {
  if (series.get("visible")) {
    series.hide();
  }
  else {
    series.show();
  }
}
function toggle(index) {
  var series = chart.series.getIndex(index);
  toggleSeries(series);
}

function toggleSeries(series) {
  if (series.get("visible")) {
    series.hide();
  }
  else {
    series.show();
  }
}

See the Pen Toggling series on and off via chart API by amCharts team (@amcharts) on CodePen.

Posted in Uncategorized