https://github.com/tomgp/simplify-line
A drop in replacement for D3s line generator that intelligently simplifies the line data
https://github.com/tomgp/simplify-line
Last synced: over 1 year ago
JSON representation
A drop in replacement for D3s line generator that intelligently simplifies the line data
- Host: GitHub
- URL: https://github.com/tomgp/simplify-line
- Owner: tomgp
- License: mit
- Created: 2015-11-29T18:40:32.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2022-12-02T13:48:51.000Z (over 3 years ago)
- Last Synced: 2025-02-15T11:03:03.250Z (over 1 year ago)
- Language: HTML
- Size: 1010 KB
- Stars: 29
- Watchers: 6
- Forks: 2
- Open Issues: 10
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
## What it is?
A simplified path generator for D3, more or less a drop in replacement for d3.line with the added ability to specify a tolerance.
## Usage
Install and use via npm `npm install --save @tomgp/simplify-line`
```
const { simplifiedLine } = require('simplify-line');
const 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 Douglas-Peucker and Radial Distance algorithms.