d3-compose

1.0.0 • Public • Published

d3-compose

In the D3 way of functions as objects, composition of functions needs to also inherit the properties of the functions being composed. This is what this small utility aims to acheive, think of it as the combination of two Underscore's functionalities: compose and extend.

This allows the extention of common D3 modules such as axis, for example:

function translate(selection, offset) {
    selection.attr("transform", "translate(0 "+offset+")");
}
var xAxis = d3.axisBottom(d3.scaleLinear()
    .domain([0, 10]).range([20, 180]));
 
var svg = d3.select("#example-1")
    .append("g")
        .call(d3.compose(translate, xAxis), 50);

For other ways of composing functions with D3 see d3-wrap.

Dependencies (0)

    Dev Dependencies (5)

    Package Sidebar

    Install

    npm i d3-compose

    Weekly Downloads

    1

    Version

    1.0.0

    License

    BSD-3-Clause

    Unpacked Size

    9.02 kB

    Total Files

    8

    Last publish

    Collaborators

    • au-phiware