diff --git a/examples/stackedAreaChart.html b/examples/stackedAreaChart.html index 246a8e1..5418d9a 100644 --- a/examples/stackedAreaChart.html +++ b/examples/stackedAreaChart.html @@ -197,9 +197,7 @@ nv.addGraph(function() { .color(keyColor) //.clipEdge(true); - chart.stacked.scatter - .sizeRange([64,64]) - .useVoronoi(false); +// chart.stacked.scatter.clipVoronoi(false); chart.xAxis .tickFormat(function(d) { return d3.time.format('%x')(new Date(d)) }); diff --git a/src/models/scatter.js b/src/models/scatter.js index e101800..5d09adc 100644 --- a/src/models/scatter.js +++ b/src/models/scatter.js @@ -189,22 +189,24 @@ nv.models.scatter = function() { vertices.push([x.range()[0] - 2000, y.range()[0] + 2000, null, null]); vertices.push([x.range()[1] + 2000, y.range()[1] - 2000, null, null]); } + + var bounds = d3.geom.polygon([ + [0,0], + [0,height], + [width,height], + [width,0] + ]); + var voronoi = d3.geom.voronoi(vertices).map(function(d, i) { return { - 'data': d.map(function(f) { - //keep the voronoi paths within the svg bounding box (for IE9 support) - f[0] = f[0] > width ? width : f[0]; - f[0] = f[0] < 0 ? 0 : f[0]; - f[1] = f[1] > height ? height : f[1]; - f[1] = f[1] < 0 ? 0 : f[1]; - return f; - }), + 'data': bounds.clip(d), 'series': vertices[i][2], 'point': vertices[i][3] } }); + var pointPaths = wrap.select('.nv-point-paths').selectAll('path') .data(voronoi); pointPaths.enter().append('path')