Browse Source

Modify region.remove API

pull/232/merge
Masayuki Tanaka 11 years ago
parent
commit
160d8bd591
  1. 27
      c3.js
  2. 2
      c3.min.js
  3. 8
      htdocs/samples/regions.html

27
c3.js

@ -4353,19 +4353,22 @@
redraw(); redraw();
return __regions; return __regions;
}; };
c3.regions.remove = function (classes, options) { c3.regions.remove = function (options) {
var regionClasses = [].concat(classes); var duration, classes, regions;
options = isDefined(options) ? options : {};
regionClasses.forEach(function (cls) { options = options || {};
var duration = isValue(options.duration) ? options.duration : 0; duration = getOption(options, "duration", __transition_duration);
svg.selectAll('.' + cls) classes = getOption(options, "classes", [CLASS.region]);
.transition().duration(duration)
.style('fill-opacity', 0) regions = main.select('.' + CLASS.regions).selectAll(classes.map(function (c) { return '.' + c; }));
.remove(); (duration ? regions.transition().duration(duration) : regions)
__regions = __regions.filter(function (region) { .style('opacity', 0)
return region.classes.indexOf(cls) < 0; .remove();
});
__regions = __regions.filter(function (region) {
return classes.indexOf(region.class) < 0;
}); });
return __regions; return __regions;
}; };

2
c3.min.js vendored

File diff suppressed because one or more lines are too long

8
htdocs/samples/regions.html

@ -53,6 +53,14 @@
chart.regions.add([{start:4.5}]); chart.regions.add([{start:4.5}]);
}, 4000); }, 4000);
setTimeout(function () {
chart.regions.add([{start:3,end:3.5,class:"region1"}, {start:4,end:4.5,class:"region2"}]);
}, 4000);
setTimeout(function () {
chart.regions.remove({classes:['region1', 'region2'], duration: 0});
}, 5000);
</script> </script>
</body> </body>

Loading…
Cancel
Save