d3-utils
Small utils to make developing with d3 easier, inspired by d3-jetpack and d3-starterkit
Install
npm install d3-utils
Usage
var d3 = var lifecycle = var ƒ = var o = var scale = x: d3scale d3 datasomeDataArray // [{label: 'Hello world', x: 0.5}, ...]
API
utils.lifecycle([enter], [update], [exit])
Makes handeling the lifecycle of a D3 selection a bit easier.
enter
Type: Function
Default noop
Calls this function with selection.enter()
update
Type: Function
Default noop
Calls this function with selection
exit
Type: Function
Default noop
Calls this function with selection.exit()
utils.get(prop, [default])
Returns a function that accesses prop
and returns it, optionally returning
default
if null
prop
Type: String
Retrieve value with key prop
from whatever object is called on the returining
function
default
Type: Any
Default null
Default value to return
utils.compose([fn...])
Takes any number of functions and composes them from left to right, returning the compose function, eg:
=== utilsx