Commit e8b7f734 authored by Masayuki Tanaka's avatar Masayuki Tanaka

Support multiple unload

parent d074ef8a
...@@ -3389,6 +3389,21 @@ ...@@ -3389,6 +3389,21 @@
done(); done();
} }
function unload(targetIds) {
targetIds.forEach(function (id) {
c3.data.targets = c3.data.targets.filter(function (t) {
return t.id !== id;
});
svg.selectAll(selectorTarget(id))
.transition()
.style('opacity', 0)
.remove();
if (__legend_show) {
legend.selectAll('.' + CLASS.legendItem + getTargetSelectorSuffix(id)).remove();
}
});
}
/*-- Draw Legend --*/ /*-- Draw Legend --*/
function toggleFocusLegend(id, focus) { function toggleFocusLegend(id, focus) {
...@@ -3685,19 +3700,10 @@ ...@@ -3685,19 +3700,10 @@
} }
}; };
c3.unload = function (targetId) { c3.unload = function (targetIds) {
c3.data.targets = c3.data.targets.filter(function (t) { // remove elements for targetId
return t.id !== targetId; unload(typeof targetIds === 'string' ? [targetIds] : targetIds);
}); // try redraw if targets exist
svg.selectAll(selectorTarget(targetId))
.transition()
.style('opacity', 0)
.remove();
if (__legend_show) {
legend.selectAll('.' + CLASS.legendItem + getTargetSelectorSuffix(targetId)).remove();
}
if (c3.data.targets.length > 0) { if (c3.data.targets.length > 0) {
redraw({withUpdateOrgXDomain: true, withUpdateXDomain: true, withLegend: true}); redraw({withUpdateOrgXDomain: true, withUpdateXDomain: true, withLegend: true});
} }
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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