2015-09-20 56 views
3

是否有像使用jQuery一样扩展D3的API?使用jQuery,我们可以像这样扩展它:如何扩展D3?

$.fn.myExtnesion = function() { 
    return $(this).each(function myPlugincode(){ 
    }); 
}; 

D3是否有类似的API?

+0

http://blogs.atlassian.com/2014/06/extending-d3-js/ – royhowie

回答

3

可以将函数直接添加到各种D3对象原型中,我们已经在我正在构建的库中使用此函数来将函数添加到d3 selections for example

例如:

d3.selection.prototype.layout = function() { 
    // your code goes here, where 'this' is the D3 selection 
}