Commit 358bd156 authored by Masayuki Tanaka's avatar Masayuki Tanaka

Fix selection by drag

parent 102c9ab1
...@@ -2954,17 +2954,17 @@ ...@@ -2954,17 +2954,17 @@
main.selectAll('.' + CLASS.shapes).selectAll('.' + CLASS.shape) main.selectAll('.' + CLASS.shapes).selectAll('.' + CLASS.shape)
.filter(function (d) { return __data_selection_isselectable(d); }) .filter(function (d) { return __data_selection_isselectable(d); })
.each(function (d, i) { .each(function (d, i) {
var _this = d3.select(this), var shape = d3.select(this),
isSelected = _this.classed(CLASS.SELECTED), isSelected = shape.classed(CLASS.SELECTED),
isIncluded = _this.classed(CLASS.INCLUDED), isIncluded = shape.classed(CLASS.INCLUDED),
_x, _y, _w, _h, toggle, isWithin = false, box; _x, _y, _w, _h, toggle, isWithin = false, box;
if (this.nodeName === 'circle') { if (shape.classed(CLASS.circle)) {
_x = _this.attr("cx") * 1; _x = shape.attr("cx") * 1;
_y = _this.attr("cy") * 1; _y = shape.attr("cy") * 1;
toggle = togglePoint; toggle = togglePoint;
isWithin = minX < _x && _x < maxX && minY < _y && _y < maxY; isWithin = minX < _x && _x < maxX && minY < _y && _y < maxY;
} }
else if (this.nodeName === 'path') { else if (shape.classed(CLASS.bar)) {
box = getPathBox(this); box = getPathBox(this);
_x = box.x; _x = box.x;
_y = box.y; _y = box.y;
...@@ -2972,12 +2972,15 @@ ...@@ -2972,12 +2972,15 @@
_h = box.height; _h = box.height;
toggle = toggleBar; toggle = toggleBar;
isWithin = !(maxX < _x || _x + _w < minX) && !(maxY < _y || _y + _h < minY); isWithin = !(maxX < _x || _x + _w < minX) && !(maxY < _y || _y + _h < minY);
} else {
// line/area selection not supported yet
return;
} }
if (isWithin ^ isIncluded) { if (isWithin ^ isIncluded) {
_this.classed(CLASS.INCLUDED, !isIncluded); shape.classed(CLASS.INCLUDED, !isIncluded);
// TODO: included/unincluded callback here // TODO: included/unincluded callback here
_this.classed(CLASS.SELECTED, !isSelected); shape.classed(CLASS.SELECTED, !isSelected);
toggle(!isSelected, _this, d, i); toggle(!isSelected, shape, d, i);
} }
}); });
} }
......
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