JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 5
  • Score
    100M100P100Q32042F
  • License MIT

Utility to make working with d3 scales less painful

Package Exports

  • d3-mapping

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (d3-mapping) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

A simple utility to make working with d3 scales easier.

Installation

npm install d3-Mapping

Usage

Designed to be used node style:

Mapping = require("d3-mapping")

Initialize a new mapping with a scale and an acessor function

x = new Mapping(xScale, xAccessor)

x has convenience methods for a number of common tasks.

  • x.place(d) returns the value a data element is mapped to. x.place will dodge d3's reassignment of the this operator, so you are free to use within .attr assignments, etc.
  • x.create_domain(data) will call d3.extent(data, x.accessor). Currently doesn't support ordinal scales.
  • x.create_axis() creates an axis for the scale, and return it, so it can be used in a method chain.
  • axis and scale attributes can be set or accessed via x.axis and x.scale respectively.

Check out the example.