Browse Source

Accept multiple args in xgrids/ygrids.remove API

pull/302/head
Masayuki Tanaka 11 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) { 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)

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 () { 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>

Loading…
Cancel
Save