I'm getting weird clipping behavior when using d3.js and conrec.js to plot contours:
This is a contour plot that is correctly depicted
This is a plot with clipping. The paths are filling incorrectly
Another example of a plot with unwanted behavior
Here is my code and approach. Data is a 31x31 value array. I make the contour and then data-bind the contour's contourList. I'm guessing something weird with the pathing is happening there!
var cliff = -1000;
data.push(d3.range(data[0].length).map(function() {
return cliff;
}));
data.unshift(d3.range(data[0].length).map(function() {
return cliff;
}));
data.forEach(function(d) {
d.push(cliff);
d.unshift(cliff);
});
var c = new Conrec,
xs = d3.range(0, data.length),
ys = d3.range(0, data[0].length),
zs = [0],
width = 300,
height = 300,
x = d3.scale.linear().range([0, width]).domain([0,
data.length
]),
y = d3.scale.linear().range([height, 0]).domain([0,
data[0].length
]);
c.contour(data, 0, xs.length - 1, 0, ys.length - 1, xs,
ys, zs.length, zs);
contourDict[key] = c;
d3.select("svg").remove();
var test = d3.select("#contour").append("svg")
.attr("width", width)
.attr("height", height)
.selectAll("path")
.data(c.contourList())
.enter().append("path")
.style("stroke", "black")
.attr("d", d3.svg.line()
.x(function(d) {
return x(d.x);
})
.y(function(d) {
return y(d.y);
}));
Thank you for your time!