Skip to content

Utility function that supports composition for `d3.call`s.

License

Notifications You must be signed in to change notification settings

au-phiware/d3-compose

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Utility function that supports composition for `d3.call`s.

Resources

License

Stars

Watchers

Forks

Packages

No packages published