d3 / d3-shape

Graphical primitives for visualization, such as lines and areas.
https://d3js.org/d3-shape
ISC License
2.48k stars 310 forks source link

Specify loop range #63

Closed sherdeadlock closed 8 years ago

sherdeadlock commented 8 years ago

Shape loop all the data. Can it provide an API that specifying a range? ex:

area(data, 5000, 6000);
mbostock commented 8 years ago

Use array.slice?

area(data.slice(5000, 6000));
sherdeadlock commented 8 years ago

It can improve some performance while changing range rapidly.

mbostock commented 8 years ago

I’m skeptical that array.slice is the performance bottleneck here. You could avoid the allocation in array.slice by copying into a pre-existing array. Or use area.defined to render a subset of the array:

area.defined(function(d, i) { return 5000 >= i && i < 6000; })(data);