Fixing issue #139. Logic in scatter.js for

when yDomain is a constant range (ie, [10,10]) is opposite
of what it should be. Added test cases in lineChartTest and
scatterChartTest.html.
master
Robin Hu 11 years ago
parent 9770970f79
commit 6d0b196892

@ -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])) {

@ -67,6 +67,14 @@
Scatter plus line: y=-0.5x + 1.0;
<svg></svg>
</div>
<div id="test14" class="chart third">
Scatter chart: duplicate y values
<svg></svg>
</div>
<div id="test15" class="chart third">
Scatter chart: duplicate x values
<svg></svg>
</div>
@ -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() {

@ -80,6 +80,11 @@
<svg></svg>
</div>
<div class='chart third' id='chart16'>
Duplicate Y coordinate points.
<svg></svg>
</div>
<div class='chart third' id='chart13'>
Chart in a overflow div with scrolls (new tooltips)
<svg></svg>
@ -90,6 +95,7 @@
<svg></svg>
</div>
<div style='clear:both;'></div>
<div class='chart third' id='chart15'>
What if there are null, Infinity and NaN values in points?
<svg></svg>
@ -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",

Loading…
Cancel
Save