# d3-interpolate-curve

> Interpolate Curves

Latest version **1.0.5** (published 2022-12-11) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install d3-interpolate-curve
pnpm add d3-interpolate-curve
yarn add d3-interpolate-curve
bun add d3-interpolate-curve
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2022-12-11 |
| First published | 2019-07-14 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 24 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 11 |
| Author | James Saunders |
| Maintainers | jamesleesaunders |
| Keywords | d3, d3-module, interpolate, interpolation, curve |

## Links

- npm: https://www.npmjs.com/package/d3-interpolate-curve
- Repository: https://github.com/jamesleesaunders/d3-interpolate-curve
- Homepage: https://github.com/jamesleesaunders/
- Issues: https://github.com/jamesleesaunders/d3-interpolate-curve/issues
- npm.io page: https://npm.io/package/d3-interpolate-curve

## Dependencies (3)

- [d3-array](https://npm.io/package/d3-array.md) ^3.2.1
- [d3-shape](https://npm.io/package/d3-shape.md) ^3.1.0
- [d3-interpolate](https://npm.io/package/d3-interpolate.md) ^3.0.1

## Alternatives

- [d3-force-3d](https://npm.io/package/d3-force-3d.md) — 1.0M weekly downloads
- [ng2-charts](https://npm.io/package/ng2-charts.md) — 486.8K weekly downloads
- [@arcgis/core](https://npm.io/package/@arcgis/core.md) — 257.8K weekly downloads
- [react-sparklines](https://npm.io/package/react-sparklines.md) — 249.3K weekly downloads
- [react-native-gifted-charts](https://npm.io/package/react-native-gifted-charts.md) — 182.3K weekly downloads

## Recent versions

- 1.0.5 (latest) — 2022-12-11
- 1.0.4 — 2022-12-09
- 1.0.3 — 2022-11-26
- 1.0.2 — 2019-08-12
- 1.0.1 — 2019-07-25
- 1.0.0 — 2019-07-16
- 0.0.2 — 2019-07-14
- 0.0.1 — 2019-07-14

## README

# d3-interpolate-curve

This module provides a select of methods for generating number value interpolators from D3 curve functions.

D3 has [d3-interpolate](https://github.com/d3/d3-interpolate) functions, for example \`d3.interpolateBasis()\`, for interpolating a series in numbers into a curve using the Basis interpolation algorithm.

D3 also has [d3-curve](https://github.com/d3/d3-shape#curves) functions, like \`d3.curveCardinal()\` and \`d3.curveMonotoneX()\`, which can be used to quickly generate SVG curve paths.

However, interpolate functions like \`d3.interpolateCardinal()\` and \`d3.interpolateMonotoneX()\` do not currently exist in D3, this limits us to to only be able to generate Cardinal and MonotoneX curves for SVG and not for things like X3D.

The [d3-interpolate-curve](https://github.com/jamesleesaunders/d3-interpolate-curve) plugin has been written to fill this gap to provide missing interpolation functions like \`d3.interpolateCardinal()\` and \`d3.interpolateMonotoneX()\` as well as \`d3.interpolateFromCurve()\`.

## Installing

If you use NPM, `npm install d3-interpolate-curve`. 
Otherwise, download the [latest release](https://github.com/jamesleesaunders/d3-interpolate-curve/releases/latest).
Alternativly in vanilla JS:

```html
<script src="https://raw.githack.com/jamesleesaunders/d3-interpolate-curve/dist/d3-interpolate.js"></script>
<script>

var interpolate = d3.interpolateFromCurve([1,2,7,2], d3.curveMonotoneX, 0.00001, 100);

</script>
```

## API Reference

<a name="interpolateFromCurve" href="#interpolateFromCurve">#</a> d3.<b>interpolateFromCurve</b>(<i>values</i>, <i>curve</i>, <i>epsilon</i>, <i>samples</i>) · [Source](https://github.com/jamesleesaunders/d3-interpolate-curve/blob/master/src/fromCurve.js), [Examples](https://observablehq.com/@jamesleesaunders/d3-interpolate-curve)

Returns interpolator based on D3 curve function; d3.curveCardinal(), d3.curveLinear(), d3.curveMonotoneX() etc. 

```js
var interpolate = d3.interpolateFromCurve([1,2,7,2], d3.curveMonotoneX, 0.00001, 100);
```

<a name="interpolateCardinal" href="#interpolateCardinal">#</a> d3.<b>interpolateCardinal</b>(<i>values</i>) · [Source](https://github.com/jamesleesaunders/d3-interpolate-curve/blob/master/src/cardinal.js), [Examples](https://observablehq.com/@jamesleesaunders/d3-interpolate-curve)

Returns interpolator based on cubic Cardinal spline.

```js
var interpolate = d3.interpolateCardinal([1,2,7,2]);
```

<a name="interpolateCatmullRom" href="#interpolateCatmullRom">#</a> d3.<b>interpolateCatmullRom</b>(<i>values</i>) · [Source](https://github.com/jamesleesaunders/d3-interpolate-curve/blob/master/src/catmullRom.js), [Examples](https://observablehq.com/@jamesleesaunders/d3-interpolate-curve)

Returns interpolator based on a cubic Catmull–Rom spline.

```js
var interpolate = d3.interpolateCatmullRom([1,2,7,2]);
```

<a name="interpolateMonotoneX" href="#interpolateMonotoneX">#</a> d3.<b>interpolateMonotoneX</b>(<i>values</i>) · [Source](https://github.com/jamesleesaunders/d3-interpolate-curve/blob/master/src/monotoneX.js), [Examples](https://observablehq.com/@jamesleesaunders/d3-interpolate-curve)

Returns interpolator based on MonotoneX spline.

```js
var interpolate = d3.interpolateMonotoneX([1,2,7,2]);
```

## Credits

* Andreas Plesch - hugh credit for goes to Andreas who came up with the original concept for this module.
* Mike Bostock - for advice on converting SVG curves.

---
_Source: https://npm.io/package/d3-interpolate-curve · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
