Browse Source

Merge branch 'chriskalmar-tooltip-fix-single-data-point'

pull/542/head
Masayuki Tanaka 10 years ago
parent
commit
2c57af4218
  1. 20
      c3.js
  2. 6
      c3.min.js
  3. 20
      src/interaction.js

20
c3.js

@ -2037,11 +2037,25 @@
rectW = function (d) {
var prevX = $$.getPrevX(d.index), nextX = $$.getNextX(d.index), dx = $$.data.xs[d.id][d.index],
w = ($$.x(nextX ? nextX : dx) - $$.x(prevX ? prevX : dx)) / 2;
return w < 0 ? 0 : w;
// if there this is a single data point make the eventRect full width (or height)
if (prevX === null && nextX === null) {
return config.axis_rotated ? $$.height : $$.width;
}
else {
return w < 0 ? 0 : w;
}
};
rectX = function (d) {
var prevX = $$.getPrevX(d.index), dx = $$.data.xs[d.id][d.index];
return ($$.x(dx) + $$.x(prevX ? prevX : dx)) / 2;
var prevX = $$.getPrevX(d.index), nextX = $$.getNextX(d.index), dx = $$.data.xs[d.id][d.index];
// if there this is a single data point position the eventRect at 0
if (prevX === null && nextX === null) {
return 0;
}
else {
return ($$.x(dx) + $$.x(prevX ? prevX : dx)) / 2;
}
};
} else {
rectW = $$.getEventRectWidth();

6
c3.min.js vendored

File diff suppressed because one or more lines are too long

20
src/interaction.js

@ -62,11 +62,25 @@ c3_chart_internal_fn.updateEventRect = function (eventRectUpdate) {
rectW = function (d) {
var prevX = $$.getPrevX(d.index), nextX = $$.getNextX(d.index), dx = $$.data.xs[d.id][d.index],
w = ($$.x(nextX ? nextX : dx) - $$.x(prevX ? prevX : dx)) / 2;
return w < 0 ? 0 : w;
// if there this is a single data point make the eventRect full width (or height)
if (prevX === null && nextX === null) {
return config.axis_rotated ? $$.height : $$.width;
}
else {
return w < 0 ? 0 : w;
}
};
rectX = function (d) {
var prevX = $$.getPrevX(d.index), dx = $$.data.xs[d.id][d.index];
return ($$.x(dx) + $$.x(prevX ? prevX : dx)) / 2;
var prevX = $$.getPrevX(d.index), nextX = $$.getNextX(d.index), dx = $$.data.xs[d.id][d.index];
// if there this is a single data point position the eventRect at 0
if (prevX === null && nextX === null) {
return 0;
}
else {
return ($$.x(dx) + $$.x(prevX ? prevX : dx)) / 2;
}
};
} else {
rectW = $$.getEventRectWidth();

Loading…
Cancel
Save