# d3-mapping

> Utility to make working with d3 scales less painful

Latest version **0.3.0** (published 2013-06-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install d3-mapping
pnpm add d3-mapping
yarn add d3-mapping
bun add d3-mapping
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.0 |
| Published | 2013-06-26 |
| First published | 2013-04-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Author | Andrew Winterman |
| Maintainers | andrewwinterman |
| Keywords | d3, scales, d3js |

## Links

- npm: https://www.npmjs.com/package/d3-mapping
- Repository: https://github.com/AWinterman/d3-mapping
- npm.io page: https://npm.io/package/d3-mapping

## Dependencies (2)

- [d3](https://npm.io/package/d3.md) ~3.2.0
- [tape](https://npm.io/package/tape.md) ~1.0.4

## 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

- 0.3.0 (latest) — 2013-06-26
- 0.2.1 — 2013-06-26
- 0.2.0 — 2013-06-14
- 0.1.1 — 2013-04-25
- 0.1.0 — 2013-04-25
- 0.0.5 — 2013-04-25
- 0.0.4 — 2013-04-24
- 0.0.3 — 2013-04-14
- 0.0.2 — 2013-04-12
- 0.0.1 — 2013-04-12

## README

# d3-Mapping #
[![Build Status](https://secure.travis-ci.org/AWinterman/d3-mapping.png)](http://travis-ci.org/AWinterman/d3-mapping) 

 A simple utility to make working with d3 scales easier.

# Installation #

npm install d3-Mapping

# Usage #

Designed to be used node style:

```js
var Mapping = require("d3-mapping")
```

Initialize a new mapping with a scale and an accessor function

```js
xScale = d3.scale.linear()
xAccessor = function(d){ return d.x }

x = new Mapping(xScale, xAccessor)
```

`x` has convenience methods for a number of common tasks. For example:

 - `x.scale` holds the reference to the original scale.
 - `x.range` and `x.domain` provide convenient access to `x.scale.domain` and
   `x.scale.range`
 - `x.place` will map data points onto the screen. It does a little dance
   to prevent D3 from overwriting its `this` object, so you can use it in d3
   attribute setters.
 - `x.compute_domain(data, ordinal)` will compute the domain of `data`, set
   `ordinal == true` to find the unique elements for the dimension rather than
   the extent
 - `x.min` and `x.max` give more flexibility in manipulating the domain of the
   mapping. If you provide one argument, the minimum (maximum) of the mapping
   domain is simply set to that argument. If you
   pass an array, they compute the minimum or maximum of the value returned by the
   accessor when applied to the array, and set the corresponding bound of
   the domain.



[Check out](http://awinterman.github.io/d3-mapping/example/) a working example,
or  [Read the literate source](http://awinterman.github.io/d3-mapping/docs/Mapping.html) for more info

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