Browse Source

Fix only one data with custom x - #548

pull/590/head
Masayuki Tanaka 10 years ago
parent
commit
9142800b93
  1. 9
      c3.js
  2. 2
      c3.min.js
  3. 9
      src/domain.js

9
c3.js

@ -1345,8 +1345,13 @@
min = 0, max = 0;
// show center of x domain if min and max are the same
if ((firstX - lastX) === 0 && !$$.isCategorized()) {
firstX = $$.isTimeSeries() ? new Date(firstX.getTime() * 0.5) : -0.5;
lastX = $$.isTimeSeries() ? new Date(lastX.getTime() * 1.5) : 0.5;
if ($$.isTimeSeries()) {
firstX = new Date(firstX.getTime() * 0.5);
lastX = new Date(lastX.getTime() * 1.5);
} else {
firstX = firstX === 0 ? 1 : (firstX * 0.5);
lastX = lastX === 0 ? -1 : (lastX * 1.5);
}
}
if (firstX || firstX === 0) {
min = $$.isTimeSeries() ? new Date(firstX.getTime() - padding.left) : firstX - padding.left;

2
c3.min.js vendored

File diff suppressed because one or more lines are too long

9
src/domain.js

@ -176,8 +176,13 @@ c3_chart_internal_fn.getXDomain = function (targets) {
min = 0, max = 0;
// show center of x domain if min and max are the same
if ((firstX - lastX) === 0 && !$$.isCategorized()) {
firstX = $$.isTimeSeries() ? new Date(firstX.getTime() * 0.5) : -0.5;
lastX = $$.isTimeSeries() ? new Date(lastX.getTime() * 1.5) : 0.5;
if ($$.isTimeSeries()) {
firstX = new Date(firstX.getTime() * 0.5);
lastX = new Date(lastX.getTime() * 1.5);
} else {
firstX = firstX === 0 ? 1 : (firstX * 0.5);
lastX = lastX === 0 ? -1 : (lastX * 1.5);
}
}
if (firstX || firstX === 0) {
min = $$.isTimeSeries() ? new Date(firstX.getTime() - padding.left) : firstX - padding.left;

Loading…
Cancel
Save