Browse Source

Fix onclick/onmouseover on bar chart as each - #390

pull/631/head
Masayuki Tanaka 10 years ago
parent
commit
a1e3376f62
  1. 12
      c3.js
  2. 2
      c3.min.js
  3. 7
      src/interaction.js
  4. 5
      src/shape.js

12
c3.js

@ -2202,12 +2202,7 @@
}
})
.filter(function (d) {
if (this.nodeName === 'circle') {
return $$.isWithinCircle(this, $$.pointSelectR(d));
}
else if (this.nodeName === 'path') {
return $$.isWithinBar(this);
}
return $$.isWithinShape(this, d);
})
.each(function (d) {
if (config.data_selection_enabled && (config.data_selection_grouped || config.data_selection_isselectable(d))) {
@ -2502,7 +2497,10 @@
c3_chart_internal_fn.isWithinShape = function (that, d) {
var $$ = this,
shape = $$.d3.select(that), isWithin;
if (that.nodeName === 'circle') {
if (!$$.isTargetToShow(d.id)) {
isWithin = false;
}
else if (that.nodeName === 'circle') {
// circle is hidden in step chart, so treat as within the click area
isWithin = $$.isStepType(d) ? true : $$.isWithinCircle(that, $$.pointSelectR(d) * 1.5);
}

2
c3.min.js vendored

File diff suppressed because one or more lines are too long

7
src/interaction.js

@ -192,12 +192,7 @@ c3_chart_internal_fn.generateEventRectsForSingleX = function (eventRectEnter) {
}
})
.filter(function (d) {
if (this.nodeName === 'circle') {
return $$.isWithinCircle(this, $$.pointSelectR(d));
}
else if (this.nodeName === 'path') {
return $$.isWithinBar(this);
}
return $$.isWithinShape(this, d);
})
.each(function (d) {
if (config.data_selection_enabled && (config.data_selection_grouped || config.data_selection_isselectable(d))) {

5
src/shape.js

@ -49,7 +49,10 @@ c3_chart_internal_fn.getShapeOffset = function (typeFilter, indices, isSub) {
c3_chart_internal_fn.isWithinShape = function (that, d) {
var $$ = this,
shape = $$.d3.select(that), isWithin;
if (that.nodeName === 'circle') {
if (!$$.isTargetToShow(d.id)) {
isWithin = false;
}
else if (that.nodeName === 'circle') {
// circle is hidden in step chart, so treat as within the click area
isWithin = $$.isStepType(d) ? true : $$.isWithinCircle(that, $$.pointSelectR(d) * 1.5);
}

Loading…
Cancel
Save