diff --git a/src/models/scatter.js b/src/models/scatter.js
index 78877d5..aa0124c 100644
--- a/src/models/scatter.js
+++ b/src/models/scatter.js
@@ -107,7 +107,7 @@ nv.models.scatter = function() {
if (y.domain()[0] === y.domain()[1])
y.domain()[0] ?
- y.domain([y.domain()[0] + y.domain()[0] * 0.01, y.domain()[1] - y.domain()[1] * 0.01])
+ y.domain([y.domain()[0] - y.domain()[0] * 0.01, y.domain()[1] + y.domain()[1] * 0.01])
: y.domain([-1,1]);
if ( isNaN(x.domain()[0])) {
diff --git a/test/ScatterChartTest.html b/test/ScatterChartTest.html
index b4593e3..ae7f2f6 100644
--- a/test/ScatterChartTest.html
+++ b/test/ScatterChartTest.html
@@ -67,6 +67,14 @@
Scatter plus line: y=-0.5x + 1.0;
+
+ Scatter chart: duplicate y values
+
+
+
+ Scatter chart: duplicate x values
+
+
@@ -103,6 +111,25 @@ defaultChartTest("test10", randomData(30,2));
scatterPlusLineTest("test11", randomDataSloped(2,0));
scatterPlusLineTest("test12", randomDataSloped(2,10));
scatterPlusLineTest("test13", randomDataSloped(-0.5,1));
+defaultChartTest("test14", [
+{key: "Duplicate Y",
+ values: [
+ {x: 0, y: 10}, {x:1, y:10},{x:2, y:10},{x:3, y:10}
+ ]
+ }
+]);
+
+defaultChartTest("test15",[
+ {key: "Duplicate X",
+ area: true,
+ values: [
+ {x: 4, y: 10},
+ {x: 4, y: 11},
+ {x: 4, y: 12},
+ {x: 4, y: 13}
+ ]
+ }
+]);
function defaultChartTest(container, data, margin) {
nv.addGraph(function() {
diff --git a/test/lineChartTest.html b/test/lineChartTest.html
index f8921ca..25a7c63 100644
--- a/test/lineChartTest.html
+++ b/test/lineChartTest.html
@@ -80,6 +80,11 @@
+
+ Duplicate Y coordinate points.
+
+
+
Chart in a overflow div with scrolls (new tooltips)
@@ -90,6 +95,7 @@
+
What if there are null, Infinity and NaN values in points?
@@ -155,6 +161,7 @@ defaultChartConfig("chart12", duplicateX(),false);
defaultChartConfig("chart13",hyperbole(), true, false, {width: 700, height: 400});
defaultChartConfig("chart14",hyperbole(), false, false, {width: 700, height: 400});
defaultChartConfig("chart15", withNaNs());
+defaultChartConfig("chart16", duplicateY(), false);
function defaultChartConfig(containerid, data, guideline, useDates, auxOptions) {
if (auxOptions === undefined) auxOptions = {};
@@ -365,6 +372,16 @@ function duplicateX() {
];
}
+function duplicateY() {
+ return [
+ {key: "Duplicate Y",
+ values: [
+ {x: 0, y: 10}, {x:1, y:10},{x:2, y:10},{x:3, y:10}
+ ]
+ }
+ ];
+}
+
function withNaNs() {
return [
{key: "NaN Points",