Line simplification
November 2015, updated March 2024
Tolerance: 3
Simplified data 169 points
Original data 4131 points
A simplified path generator for D3. Remove points without losing much information. A drop in replacement for the basic functionality d3.line with the added ability to specify a tolerance.
In the case here:
var simple = simplePath() .tolerance(3) .x(function(d){ return dateScale(d.date); }) .y(function(d){ return valueScale(d.value); })
Based on Simplify.js a tiny high-performance JavaScript polyline simplification library by Vladimir Agafonkin, extracted from Leaflet, a JS interactive maps library by the same author.
It uses a combination of Ramer-Douglas-Peucker and Radial Distance algorithms.
Source code is on GitHub