Fixing issue #219. Moving the jitter logic to after the scatter point's scale

has been determined.
Added line chart and scatter chart tests.
master
Robin Hu 11 years ago
parent 0ead511d72
commit 9f2280bee7

@ -167,11 +167,11 @@ nv.models.scatter = function() {
// *Injecting series and point index for reference
/* *Adding a 'jitter' to the points, because there's an issue in d3.geom.voronoi.
*/
var pX = getX(point,pointIndex) + Math.random() * 1e-7;
var pY = getY(point,pointIndex) + Math.random() * 1e-7;
var pX = getX(point,pointIndex);
var pY = getY(point,pointIndex);
return [x(pX),
y(pY),
return [x(pX)+ Math.random() * 1e-7,
y(pY)+ Math.random() * 1e-7,
groupIndex,
pointIndex, point]; //temp hack to add noise untill I think of a better way so there are no duplicates
})

@ -75,7 +75,10 @@
Scatter chart: duplicate x values
<svg></svg>
</div>
<div id="test16" class="chart third">
Scatter chart: extremely small data points (1e-10)
<svg></svg>
</div>
</div>
@ -131,6 +134,8 @@ defaultChartTest("test15",[
}
]);
defaultChartTest("test16",tinyPoints());
function defaultChartTest(container, data, margin) {
nv.addGraph(function() {
var chart;
@ -219,4 +224,16 @@ function randomDataSloped(slope,intercept) { //# groups,# points per group
return data;
}
function tinyPoints() {
var rval = {key: "Tiny points", values: []};
for(var i =1; i < 20; i++) {
rval.values.push({
x: Math.random() * 1e-10,
y: Math.random() * 1e-10
});
}
return [rval];
}
</script>

@ -100,6 +100,10 @@
What if there are null, Infinity and NaN values in points?
<svg></svg>
</div>
<div class='chart third' id='chart17'>
Chart with very small, 1e-10, points (old tooltips)
<svg></svg>
</div>
</div>
<script src="../lib/d3.v3.js"></script>
@ -162,6 +166,7 @@ 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);
defaultChartConfig("chart17", tinyPoints(), false);
function defaultChartConfig(containerid, data, guideline, useDates, auxOptions) {
if (auxOptions === undefined) auxOptions = {};
@ -400,4 +405,15 @@ function withNaNs() {
}
]
}
function tinyPoints() {
var rval = {key: "Tiny points", values: []};
for(var i =1; i < 20; i++) {
rval.values.push({
x: i,
y: Math.random() * 1e-10
});
}
return [rval];
}
</script>

Loading…
Cancel
Save