Commit 93c6a1eb authored by Masayuki Tanaka's avatar Masayuki Tanaka

Refactor toggle for path

parent 40de0881
...@@ -4649,7 +4649,7 @@ ...@@ -4649,7 +4649,7 @@
_y = box.y; _y = box.y;
_w = box.width; _w = box.width;
_h = box.height; _h = box.height;
toggle = $$.toggleBar; toggle = $$.togglePath;
isWithin = !(maxX < _x || _x + _w < minX) && !(maxY < _y || _y + _h < minY); isWithin = !(maxX < _x || _x + _w < minX) && !(maxY < _y || _y + _h < minY);
} else { } else {
// line/area selection not supported yet // line/area selection not supported yet
...@@ -4720,27 +4720,23 @@ ...@@ -4720,27 +4720,23 @@
c3_chart_internal_fn.togglePoint = function (selected, target, d, i) { c3_chart_internal_fn.togglePoint = function (selected, target, d, i) {
selected ? this.selectPoint(target, d, i) : this.unselectPoint(target, d, i); selected ? this.selectPoint(target, d, i) : this.unselectPoint(target, d, i);
}; };
c3_chart_internal_fn.selectBar = function (target, d) { c3_chart_internal_fn.selectPath = function (target, d) {
var $$ = this; var $$ = this;
$$.config.data_onselected.call($$, d, target.node()); $$.config.data_onselected.call($$, d, target.node());
target.transition().duration(100) target.transition().duration(100)
.style("fill", function () { return $$.d3.rgb($$.color(d)).brighter(0.75); }); .style("fill", function () { return $$.d3.rgb($$.color(d)).brighter(0.75); });
}; };
c3_chart_internal_fn.unselectBar = function (target, d) { c3_chart_internal_fn.unselectPath = function (target, d) {
var $$ = this; var $$ = this;
$$.config.data_onunselected.call($$, d, target.node()); $$.config.data_onunselected.call($$, d, target.node());
target.transition().duration(100) target.transition().duration(100)
.style("fill", function () { return $$.color(d); }); .style("fill", function () { return $$.color(d); });
}; };
c3_chart_internal_fn.toggleBar = function (selected, target, d, i) { c3_chart_internal_fn.togglePath = function (selected, target, d, i) {
selected ? this.selectBar(target, d, i) : this.unselectBar(target, d, i); selected ? this.selectPath(target, d, i) : this.unselectPath(target, d, i);
};
c3_chart_internal_fn.toggleArc = function (selected, target, d, i) {
this.toggleBar(selected, target, d, i);
}; };
c3_chart_internal_fn.getToggle = function (that, d) { c3_chart_internal_fn.getToggle = function (that, d) {
var $$ = this, var $$ = this, toggle;
shape = $$.d3.select(that), toggle;
if (that.nodeName === 'circle') { if (that.nodeName === 'circle') {
if ($$.isStepType(d)) { if ($$.isStepType(d)) {
// circle is hidden in step chart, so treat as within the click area // circle is hidden in step chart, so treat as within the click area
...@@ -4750,11 +4746,7 @@ ...@@ -4750,11 +4746,7 @@
} }
} }
else if (that.nodeName === 'path') { else if (that.nodeName === 'path') {
if (shape.classed(CLASS.bar)) { toggle = $$.togglePath;
toggle = $$.toggleBar;
} else { // would be arc
toggle = $$.toggleArc;
}
} }
return toggle; return toggle;
}; };
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -41,7 +41,7 @@ c3_chart_internal_fn.drag = function (mouse) { ...@@ -41,7 +41,7 @@ c3_chart_internal_fn.drag = function (mouse) {
_y = box.y; _y = box.y;
_w = box.width; _w = box.width;
_h = box.height; _h = box.height;
toggle = $$.toggleBar; toggle = $$.togglePath;
isWithin = !(maxX < _x || _x + _w < minX) && !(maxY < _y || _y + _h < minY); isWithin = !(maxX < _x || _x + _w < minX) && !(maxY < _y || _y + _h < minY);
} else { } else {
// line/area selection not supported yet // line/area selection not supported yet
......
...@@ -27,27 +27,23 @@ c3_chart_internal_fn.unselectPoint = function (target, d, i) { ...@@ -27,27 +27,23 @@ c3_chart_internal_fn.unselectPoint = function (target, d, i) {
c3_chart_internal_fn.togglePoint = function (selected, target, d, i) { c3_chart_internal_fn.togglePoint = function (selected, target, d, i) {
selected ? this.selectPoint(target, d, i) : this.unselectPoint(target, d, i); selected ? this.selectPoint(target, d, i) : this.unselectPoint(target, d, i);
}; };
c3_chart_internal_fn.selectBar = function (target, d) { c3_chart_internal_fn.selectPath = function (target, d) {
var $$ = this; var $$ = this;
$$.config.data_onselected.call($$, d, target.node()); $$.config.data_onselected.call($$, d, target.node());
target.transition().duration(100) target.transition().duration(100)
.style("fill", function () { return $$.d3.rgb($$.color(d)).brighter(0.75); }); .style("fill", function () { return $$.d3.rgb($$.color(d)).brighter(0.75); });
}; };
c3_chart_internal_fn.unselectBar = function (target, d) { c3_chart_internal_fn.unselectPath = function (target, d) {
var $$ = this; var $$ = this;
$$.config.data_onunselected.call($$, d, target.node()); $$.config.data_onunselected.call($$, d, target.node());
target.transition().duration(100) target.transition().duration(100)
.style("fill", function () { return $$.color(d); }); .style("fill", function () { return $$.color(d); });
}; };
c3_chart_internal_fn.toggleBar = function (selected, target, d, i) { c3_chart_internal_fn.togglePath = function (selected, target, d, i) {
selected ? this.selectBar(target, d, i) : this.unselectBar(target, d, i); selected ? this.selectPath(target, d, i) : this.unselectPath(target, d, i);
};
c3_chart_internal_fn.toggleArc = function (selected, target, d, i) {
this.toggleBar(selected, target, d, i);
}; };
c3_chart_internal_fn.getToggle = function (that, d) { c3_chart_internal_fn.getToggle = function (that, d) {
var $$ = this, var $$ = this, toggle;
shape = $$.d3.select(that), toggle;
if (that.nodeName === 'circle') { if (that.nodeName === 'circle') {
if ($$.isStepType(d)) { if ($$.isStepType(d)) {
// circle is hidden in step chart, so treat as within the click area // circle is hidden in step chart, so treat as within the click area
...@@ -57,11 +53,7 @@ c3_chart_internal_fn.getToggle = function (that, d) { ...@@ -57,11 +53,7 @@ c3_chart_internal_fn.getToggle = function (that, d) {
} }
} }
else if (that.nodeName === 'path') { else if (that.nodeName === 'path') {
if (shape.classed(CLASS.bar)) { toggle = $$.togglePath;
toggle = $$.toggleBar;
} else { // would be arc
toggle = $$.toggleArc;
}
} }
return toggle; return toggle;
}; };
......
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