Commit 347eec0d authored by Masayuki Tanaka's avatar Masayuki Tanaka

Refactor empty selection

parent 00e33f1f
...@@ -2328,6 +2328,10 @@ ...@@ -2328,6 +2328,10 @@
return isSplineType(d) ? "cardinal" : isStepType(d) ? "step-after" : "linear"; return isSplineType(d) ? "cardinal" : isStepType(d) ? "step-after" : "linear";
} }
function getEmptySelection() {
return d3.selectAll([]);
}
//-- Selection --// //-- Selection --//
function selectPoint(target, d, i) { function selectPoint(target, d, i) {
...@@ -3364,6 +3368,8 @@ ...@@ -3364,6 +3368,8 @@
var duration, durationForExit, durationForAxis, waitForDraw = generateWait(); var duration, durationForExit, durationForAxis, waitForDraw = generateWait();
var targetsToShow = filterTargetsToShow(c3.data.targets), tickValues, i, intervalForCulling; var targetsToShow = filterTargetsToShow(c3.data.targets), tickValues, i, intervalForCulling;
xgrid = xgridLines = mainCircle = mainText = getEmptySelection();
options = options || {}; options = options || {};
withY = getOption(options, "withY", true); withY = getOption(options, "withY", true);
withSubchart = getOption(options, "withSubchart", true); withSubchart = getOption(options, "withSubchart", true);
...@@ -3497,8 +3503,6 @@ ...@@ -3497,8 +3503,6 @@
xgrid.attr(xgridAttr) xgrid.attr(xgridAttr)
.style("opacity", function () { return +d3.select(this).attr(__axis_rotated ? 'y1' : 'x1') === (__axis_rotated ? height : 0) ? 0 : 1; }); .style("opacity", function () { return +d3.select(this).attr(__axis_rotated ? 'y1' : 'x1') === (__axis_rotated ? height : 0) ? 0 : 1; });
xgrid.exit().remove(); xgrid.exit().remove();
} else {
xgrid = d3.selectAll([]);
} }
if (notEmpty(__grid_x_lines)) { if (notEmpty(__grid_x_lines)) {
xgridLines = main.select('.' + CLASS.xgridLines).selectAll('.' + CLASS.xgridLine) xgridLines = main.select('.' + CLASS.xgridLines).selectAll('.' + CLASS.xgridLine)
...@@ -3520,8 +3524,6 @@ ...@@ -3520,8 +3524,6 @@
xgridLines.exit().transition().duration(duration) xgridLines.exit().transition().duration(duration)
.style("opacity", 0) .style("opacity", 0)
.remove(); .remove();
} else {
xgridLines = d3.selectAll([]);
} }
// Y-Grid // Y-Grid
if (withY && __grid_y_show) { if (withY && __grid_y_show) {
...@@ -3636,8 +3638,6 @@ ...@@ -3636,8 +3638,6 @@
mainCircle mainCircle
.style("opacity", initialOpacity); .style("opacity", initialOpacity);
mainCircle.exit().remove(); mainCircle.exit().remove();
} else {
mainCircle = d3.selectAll([]);
} }
if (hasDataLabel()) { if (hasDataLabel()) {
...@@ -3656,8 +3656,6 @@ ...@@ -3656,8 +3656,6 @@
.transition().duration(durationForExit) .transition().duration(durationForExit)
.style('fill-opacity', 0) .style('fill-opacity', 0)
.remove(); .remove();
} else {
mainText = d3.selectAll([]);
} }
// arc // arc
......
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