Browse Source

Refactor toggle for path

pull/555/head
Masayuki Tanaka 10 years ago
parent
commit
93c6a1eb8a
  1. 22
      c3.js
  2. 4
      c3.min.js
  3. 2
      src/drag.js
  4. 20
      src/selection.js

22
c3.js

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

4
c3.min.js vendored

File diff suppressed because one or more lines are too long

2
src/drag.js

@ -41,7 +41,7 @@ c3_chart_internal_fn.drag = function (mouse) {
_y = box.y;
_w = box.width;
_h = box.height;
toggle = $$.toggleBar;
toggle = $$.togglePath;
isWithin = !(maxX < _x || _x + _w < minX) && !(maxY < _y || _y + _h < minY);
} else {
// line/area selection not supported yet

20
src/selection.js

@ -27,27 +27,23 @@ c3_chart_internal_fn.unselectPoint = function (target, d, i) {
c3_chart_internal_fn.togglePoint = function (selected, 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;
$$.config.data_onselected.call($$, d, target.node());
target.transition().duration(100)
.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;
$$.config.data_onunselected.call($$, d, target.node());
target.transition().duration(100)
.style("fill", function () { return $$.color(d); });
};
c3_chart_internal_fn.toggleBar = function (selected, target, d, i) {
selected ? this.selectBar(target, d, i) : this.unselectBar(target, d, i);
};
c3_chart_internal_fn.toggleArc = function (selected, target, d, i) {
this.toggleBar(selected, target, d, i);
c3_chart_internal_fn.togglePath = function (selected, target, d, i) {
selected ? this.selectPath(target, d, i) : this.unselectPath(target, d, i);
};
c3_chart_internal_fn.getToggle = function (that, d) {
var $$ = this,
shape = $$.d3.select(that), toggle;
var $$ = this, toggle;
if (that.nodeName === 'circle') {
if ($$.isStepType(d)) {
// 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) {
}
}
else if (that.nodeName === 'path') {
if (shape.classed(CLASS.bar)) {
toggle = $$.toggleBar;
} else { // would be arc
toggle = $$.toggleArc;
}
toggle = $$.togglePath;
}
return toggle;
};

Loading…
Cancel
Save