0.4.1 • Published 6 years ago

d3-wrap v0.4.1

Weekly downloads
2
License
BSD-3-Clause
Repository
github
Last release
6 years ago

d3-wrap

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: wrap and extend.

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

var height = ...;

var xAxis = d3.axisBottom();

xAxis = d3.wrap(xAxis, function(selection, xAxis) {
        return xAxis(
            selection.append("g")
                .attr("class", "x axis")
                .attr("transform", "translate(0 " + height + ")"));
    });

var svg = d3.select("body").append("svg");

svg.call(xAxis.domain([...]));

If the selection is under transition, the transition will be correctly preserved through the call.

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

0.4.1

6 years ago

0.4.0

6 years ago

0.3.1

6 years ago

0.3.0

6 years ago

0.1.0

8 years ago