Browse Source

Accept multiple args in xgrids/ygrids.remove API

pull/302/head
Masayuki Tanaka 10 years ago
parent
commit
4c6e2a99ae
  1. 19
      c3.js
  2. 2
      c3.min.js
  3. 13
      htdocs/samples/grid_x_lines.html

19
c3.js

@ -4655,15 +4655,20 @@
function isArc(d) {
return 'data' in d && hasTarget(c3.data.targets, d.data.id);
}
function getGridFilter(params) {
params = params || {};
return function (line) {
return !(('value' in params && line.value === params.value) || ('class' in params && line.class === params.class));
};
function getGridFilterToRemove(params) {
return params ? function (line) {
var found = false;
[].concat(params).forEach(function (param) {
if ((('value' in param && line.value === params.value) || ('class' in param && line.class === params.class))) {
found = true;
}
});
return found;
} : function () { return true; };
}
function removeGridLines(params, forX) {
var toShow = getGridFilter(params),
toRemove = function (line) { return !toShow(line); },
var toRemove = getGridFilterToRemove(params),
toShow = function (line) { return !toRemove(line); },
classLines = forX ? CLASS.xgridLines : CLASS.ygridLines,
classLine = forX ? CLASS.xgridLine : CLASS.ygridLine;
main.select('.' + classLines).selectAll('.' + classLine).filter(toRemove)

2
c3.min.js vendored

File diff suppressed because one or more lines are too long

13
htdocs/samples/grid_x_lines.html

@ -44,6 +44,19 @@
setTimeout(function () {
chart.xgrids.remove({class:'hoge'});
}, 5000);
setTimeout(function () {
chart.xgrids.remove([{value: 1}, {value: 4}]);
}, 6000);
setTimeout(function () {
chart.xgrids([{value: 1, text:'Label 1'}, {value: 4, text: 'Label 4'}]);
}, 7000);
setTimeout(function () {
chart.xgrids.remove();
}, 8000);
</script>
</body>
</html>

Loading…
Cancel
Save