c3js / c3

:bar_chart: A D3-based reusable chart library
http://c3js.org
MIT License
9.33k stars 1.39k forks source link

API Regions Remove not deleting regions #2819

Closed gregorbaird1 closed 3 years ago

gregorbaird1 commented 3 years ago

in: api.region.ts function: Chart.prototype.regions.remove = function (options) {.........

the code snipit

  config.regions = config.regions.filter(function (region) {
      var found = false;
      if (!region['class']) {
          return true;
      }
      region['class'].split(' ').forEach(function (c) {
          if (classes.indexOf(c) >= 0) {
              found = true;
          }
      });
      return !found;
  });

does not remove the regions from config.regions because the filter function always returns true.

in my opinion the code should be:

  config.regions = config.regions.filter(function (region) {
      if (!region['class']) {
          return true;
      }
      region['class'].split(' ').forEach(function (c) {
          if (classes.indexOf(c) >= 0) {
              found = true;
          }
      });
      return false;
  });

ie the filter function should return false to remove the region

gregorbaird1 commented 3 years ago

Sorry suggested code is wrong. And now I can't work out why the original code does not remove the regions from the config Sorry will keep looking