Commit 9142800b authored by Masayuki Tanaka's avatar Masayuki Tanaka

Fix only one data with custom x - #548

parent 4a624a1f
...@@ -1345,8 +1345,13 @@ ...@@ -1345,8 +1345,13 @@
min = 0, max = 0; min = 0, max = 0;
// show center of x domain if min and max are the same // show center of x domain if min and max are the same
if ((firstX - lastX) === 0 && !$$.isCategorized()) { if ((firstX - lastX) === 0 && !$$.isCategorized()) {
firstX = $$.isTimeSeries() ? new Date(firstX.getTime() * 0.5) : -0.5; if ($$.isTimeSeries()) {
lastX = $$.isTimeSeries() ? new Date(lastX.getTime() * 1.5) : 0.5; 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) { if (firstX || firstX === 0) {
min = $$.isTimeSeries() ? new Date(firstX.getTime() - padding.left) : firstX - padding.left; min = $$.isTimeSeries() ? new Date(firstX.getTime() - padding.left) : firstX - padding.left;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -176,8 +176,13 @@ c3_chart_internal_fn.getXDomain = function (targets) { ...@@ -176,8 +176,13 @@ c3_chart_internal_fn.getXDomain = function (targets) {
min = 0, max = 0; min = 0, max = 0;
// show center of x domain if min and max are the same // show center of x domain if min and max are the same
if ((firstX - lastX) === 0 && !$$.isCategorized()) { if ((firstX - lastX) === 0 && !$$.isCategorized()) {
firstX = $$.isTimeSeries() ? new Date(firstX.getTime() * 0.5) : -0.5; if ($$.isTimeSeries()) {
lastX = $$.isTimeSeries() ? new Date(lastX.getTime() * 1.5) : 0.5; 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) { if (firstX || firstX === 0) {
min = $$.isTimeSeries() ? new Date(firstX.getTime() - padding.left) : firstX - padding.left; min = $$.isTimeSeries() ? new Date(firstX.getTime() - padding.left) : firstX - padding.left;
......
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