Commit 4c6e2a99 authored by Masayuki Tanaka's avatar Masayuki Tanaka

Accept multiple args in xgrids/ygrids.remove API

parent c81f5a29
...@@ -4655,15 +4655,20 @@ ...@@ -4655,15 +4655,20 @@
function isArc(d) { function isArc(d) {
return 'data' in d && hasTarget(c3.data.targets, d.data.id); return 'data' in d && hasTarget(c3.data.targets, d.data.id);
} }
function getGridFilter(params) { function getGridFilterToRemove(params) {
params = params || {}; return params ? function (line) {
return function (line) { var found = false;
return !(('value' in params && line.value === params.value) || ('class' in params && line.class === params.class)); [].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) { function removeGridLines(params, forX) {
var toShow = getGridFilter(params), var toRemove = getGridFilterToRemove(params),
toRemove = function (line) { return !toShow(line); }, toShow = function (line) { return !toRemove(line); },
classLines = forX ? CLASS.xgridLines : CLASS.ygridLines, classLines = forX ? CLASS.xgridLines : CLASS.ygridLines,
classLine = forX ? CLASS.xgridLine : CLASS.ygridLine; classLine = forX ? CLASS.xgridLine : CLASS.ygridLine;
main.select('.' + classLines).selectAll('.' + classLine).filter(toRemove) main.select('.' + classLines).selectAll('.' + classLine).filter(toRemove)
......
...@@ -44,6 +44,19 @@ ...@@ -44,6 +44,19 @@
setTimeout(function () { setTimeout(function () {
chart.xgrids.remove({class:'hoge'}); chart.xgrids.remove({class:'hoge'});
}, 5000); }, 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> </script>
</body> </body>
</html> </html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment